当前位置: 首页>>代码示例>>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;未经允许,请勿转载。