當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Permission::with方法代碼示例

本文整理匯總了PHP中app\Permission::with方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permission::with方法的具體用法?PHP Permission::with怎麽用?PHP Permission::with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Permission的用法示例。


在下文中一共展示了Permission::with方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAllPermissions

 /**
  * @param string $order_by
  * @param string $sort
  * @param bool $withRoles
  * @return mixed
  */
 public function getAllPermissions($order_by = 'id', $sort = 'asc', $withRoles = true)
 {
     if ($withRoles) {
         return Permission::with('roles')->orderBy($order_by, $sort)->get();
     }
     return Permission::orderBy($order_by, $sort)->get();
 }
開發者ID:num3thod,項目名稱:laravel-5-boilerplate,代碼行數:13,代碼來源:EloquentPermissionRepository.php

示例2: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->authorize('permissions-edit');
     $permission = Permission::with('roles')->findOrFail($id);
     $roles = Role::orderBy('display_name')->get();
     return view('permissions.edit', compact('permission', 'roles'));
 }
開發者ID:guenthertheilen,項目名稱:laravel-boilerplate,代碼行數:13,代碼來源:PermissionsController.php

示例3: getPermissions

 /**
  * Fetch the collection of site permissions.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  * @todo find better solution to prevent missing table error whe permissions table not yet migrated.
  */
 protected function getPermissions()
 {
     try {
         return Permission::with('roles')->get();
     } catch (\Exception $e) {
         return [];
     }
 }
開發者ID:LichtAnd,項目名稱:nkg,代碼行數:14,代碼來源:AuthServiceProvider.php

示例4: getPermissions

 /**
  * Fetch the collection of site permissions.
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 protected function getPermissions()
 {
     try {
         return Permission::with('roles')->get();
     } catch (\Exception $e) {
         \Log::alert('No se pudo registrar los permisos');
         return [];
     }
 }
開發者ID:Aphix-Labs,項目名稱:laravel-aphix-boilerplate,代碼行數:14,代碼來源:AuthServiceProvider.php

示例5: boot

 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     parent::registerPolicies($gate);
     $permissions = \App\Permission::with('roles')->get();
     foreach ($permissions as $permission) {
         $gate->define($permission->name, function ($user) use($permission) {
             return $user->hasPermission($permission);
         });
     }
 }
開發者ID:waeltech,項目名稱:lara,代碼行數:16,代碼來源:AuthServiceProvider.php

示例6: boot

 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     $permissions = Permission::with('roles')->get();
     foreach ($permissions as $permission) {
         $gate->define($permission->slug, function ($user) use($permission) {
             return $permission->roles->contains($user->role);
         });
     }
     // $gate->define('show-product', function($user, $product){
     //     return $user->id == $product->supplier_id;
     // });
 }
開發者ID:EnnioSimoes,項目名稱:acl-laravel,代碼行數:19,代碼來源:AuthServiceProvider.php

示例7: boot

 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     parent::registerPolicies($gate);
     $gate->before(function ($user, $ability) {
         if ($user->isAdmin()) {
             return true;
         }
     });
     if (\Schema::hasTable('permissions')) {
         $permissions = \App\Permission::with('roles')->get();
         foreach ($permissions as $permission) {
             $gate->define($permission->slug, function ($user) use($permission) {
                 return $user->hasPermission($permission);
             });
         }
     }
 }
開發者ID:litemax,項目名稱:LaravelBlog,代碼行數:23,代碼來源:AuthServiceProvider.php

示例8: getPermissions

 protected function getPermissions()
 {
     return Permission::with('roles')->get();
 }
開發者ID:rintosarkar,項目名稱:capital,代碼行數:4,代碼來源:AuthServiceProvider.php

示例9: getPermissions

 public function getPermissions()
 {
     return Permission::with('roles')->get();
 }
開發者ID:nayed,項目名稱:lab,代碼行數:4,代碼來源:AuthServiceProvider.php

示例10: index

 public function index()
 {
     $permissions = Permission::with('roles')->paginate(20);
     return view('admin.permission.index', ['permissions' => $permissions]);
 }
開發者ID:nguyenvanduocit,項目名稱:Laravel-Source-Account-Manager,代碼行數:5,代碼來源:PermissionController.php

示例11: function

// Route::post('/api/users/assign/role', 'UserPivotApiController@assignRole');
Route::group(['prefix' => 'api'], function () {
    Route::get('user-data/{id}', 'IndexController@user');
    Route::get('user-id', 'UserPivotApiController@userId');
    Route::get('users/pivots', 'UserPivotApiController@index');
    Route::post('users/assign/role', 'UserPivotApiController@assignRole');
});
Route::group(['middleware' => ['web']], function () {
    //
});
Route::group(['middleware' => 'web'], function () {
    Route::auth();
    Route::get('/home', 'HomeController@index');
});
Route::group(['middleware' => 'auth'], function () {
    Route::resource('posts', 'PostsController');
});
Route::get('users', function () {
    return \App\User::all();
});
Route::get('users/{id}', function ($id) {
    return \App\User::with('roles')->find(1);
});
Route::get('roles', function () {
    return \App\Permission::with('roles')->get();
});
Route::group(['prefix' => 'acl'], function () {
    Route::get('', 'UserPivotController@index');
    Route::get('users', 'UserPivotController@allUser');
    Route::get('users/{id}', ['as' => 'user.show', 'uses' => 'UserPivotController@show']);
});
開發者ID:philippineglobaloutsourcing,項目名稱:Laravel-ACL,代碼行數:31,代碼來源:routes.php

示例12: getSystemUsers

 public function getSystemUsers()
 {
     return \App\Permission::with('users')->get()->get(1)->users;
 }
開發者ID:crow1796,項目名稱:technologyRIS,代碼行數:4,代碼來源:UserRepository.php


注:本文中的app\Permission::with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。