本文整理匯總了PHP中app\Menu::whereHas方法的典型用法代碼示例。如果您正苦於以下問題:PHP Menu::whereHas方法的具體用法?PHP Menu::whereHas怎麽用?PHP Menu::whereHas使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Menu
的用法示例。
在下文中一共展示了Menu::whereHas方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: function
Route::get('profiles', ['as' => 'admin.profiles', 'uses' => 'Admin\\AdminController@profile']);
Route::resource('menus', 'Admin\\MenuController');
//Route::resource('profiles', 'Admin\ProfileController', ['only' => ['index', 'edit', 'update']]);
});
Route::group(['prefix' => 'admin'], function () {
//Route::get('profile', ['as' => 'profile.show', 'uses' => 'Admin\ProfileController@showProfile']);
Route::patch('profile/{profile}', ['as' => 'profile.update', 'uses' => 'Admin\\ProfileController@updateProfile']);
Route::get('profile/{profile?}', ['as' => 'profile.show', 'uses' => 'Admin\\ProfileController@show']);
Route::patch('profile/{profile}/upload', ['as' => 'profile.avatar', 'uses' => 'Admin\\ProfileController@updateImage']);
});
});
View::composer('acl::*', function ($view) {
$menus = [];
$menu_items = [];
$user = [];
if (Auth::check()) {
$menus = \App\Menu::whereHas('roles', function ($q) {
$roles = Auth::user()->roles->lists('id');
$q->whereIn('id', $roles)->where('parent_id', 0);
})->orderBy('sort_order', 'ASC')->distinct()->get();
$menu_items = \App\Menu::whereHas('roles', function ($q) {
$roles = Auth::user()->roles->lists('id');
$q->whereIn('id', $roles);
//->where('parent_id', 0);
})->orderBy('sort_order', 'ASC')->distinct()->paginate();
//dd(count($menu_items));
$userId = \Auth::user()->id;
$user = \App\User::with('profile')->findOrFail($userId);
}
$view->with(compact('menus', 'menu_items', 'user'));
});