View::share([
'messageCount' => Message::count(),
]);
User::whereHas('companies', function ($query) {
$query->where('active', true);
})->get();
Route::get('/pages/{page:slug}', 'PageController@show')->name('pages.show');
public function show(Page $page)
{
$page->increment('views');
return view('page.show', compact('page'));
}
А как делать конкретные страницы по типу site.ru/about/, не говорят.
Route::view('about', 'page.about')->name('about');
No query results for model
'user' => $this->user->name,
if(! $token = Auth::login($user)){
return response()->json(['error' => 'Unauthorized'], 401);
}
Gate::define('view-admin', function (User $user) {
return $user->is_admin;
});
Route::middleware(['web', 'can:view-admin'])
->namespace($this->namespace)
->group(base_path('routes/admin/web.php'));
@can('view-admin')
кнопка
@endcan
if ($user->can('view-admin')) {
// code
}
public function blackEmail()
{
return $this->hasOne('App\Models\BlackEmail', 'email', 'email');
}
User::doesntHave('blackEmail')
->get();
User::where('has_black_email', false)
->get();
$admin->notify(new Message());
public function toMail($notifiable)
{
return (new MailMessage)
->cc('admin@example.com')
->markdown('mail');
}
$orders = Order::with('status')
->get();
$store->branch->stores;
Store::with('branch.stores')
->get();
Str::uuid()->toString()
$cityId = $request->input('city_id');
$categoryId = $request->input('category_id');
$adverts = Advert::when($cityId, function ($query, $cityId) {
$query->where('city_id', $cityId);
})
->when($categoryId, function ($query, $categoryId) {
$query->where('category_id', $categoryId);
})
->get();
$user->branches()
->with('warehouses.prices')
->get();
Warehouse::whereHas('branche', function ($query) {
$query->where('user_id', Auth::id());
})
->get();