当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::get方法代码示例

本文整理汇总了PHP中app\Permission::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::get方法的具体用法?PHP Permission::get怎么用?PHP Permission::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Permission的用法示例。


在下文中一共展示了Permission::get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $this->command->info('Seeding permission to role associations.');
     $permissions = Permission::get()->modelKeys();
     // Insert default permissions.
     foreach ($this->slugs() as $role_id => $slugs) {
         foreach ($slugs as $slug_key => $slug_value) {
             if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
                 $permission_id = $slug_key;
                 $permission_value = !!$slug_value;
             } else {
                 $permission_id = $slug_value;
                 $permission_value = true;
             }
             if (in_array($permission_id, $permissions)) {
                 RolePermission::firstOrCreate(['role_id' => $role_id, 'permission_id' => $permission_id, 'value' => $permission_value]);
             } else {
                 $this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
             }
         }
     }
     // Give admin permissions.
     if (count($permissions)) {
         foreach ($permissions as $permission_id) {
             $permission = RolePermission::firstOrNew(['role_id' => Role::ID_ADMIN, 'permission_id' => $permission_id]);
             $permission->value = 1;
             $permission->save();
         }
     }
 }
开发者ID:Cipherwraith,项目名称:infinity-next,代码行数:30,代码来源:RoleSeeder.php

示例2: run

 public function run()
 {
     $this->command->info('Seeding permission to role associations.');
     $permissions = Permission::get()->modelKeys();
     // Insert default permissions.
     foreach ($this->slugs() as $role_id => $slugs) {
         foreach ($slugs as $slug_key => $slug_value) {
             if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
                 $permission_id = $slug_key;
                 $permission_value = !!$slug_value;
             } else {
                 $permission_id = $slug_value;
                 $permission_value = true;
             }
             if (in_array($permission_id, $permissions)) {
             } else {
                 $this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
             }
         }
     }
     // Give admin permissions.
     if (count($permissions)) {
         $role = Role::find(Role::ID_ADMIN);
         $role->permissions()->detach();
         $attachments = [];
         foreach ($permissions as $permission_id) {
             $attachments[] = ['permission_id' => $permission_id, 'value' => 1];
         }
         $role->permissions()->attach($attachments);
     }
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:31,代码来源:RoleSeeder.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $role = Role::findOrFail($id);
     $role->load('perms');
     $permissions = Permission::get();
     $tab = 'roles';
     $columnSizes = ['sm' => [4, 8], 'lg' => [2, 10]];
     return view('admin.roles.edit', compact('role', 'permissions', 'tab', 'columnSizes'));
 }
开发者ID:Shoodey,项目名称:Events,代码行数:15,代码来源:RolesController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('roles')->insert(['name' => 'admin', 'display_name' => 'Administrator', 'description' => "Complete access of administration.", 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     foreach (Permission::get() as $permission) {
         DB::table('permission_role')->insert(['permission_id' => $permission->id, 'role_id' => 1]);
     }
     DB::table('role_user')->insert(['user_id' => '1', 'role_id' => '1']);
     DB::table('role_user')->insert(['user_id' => '2', 'role_id' => '1']);
 }
开发者ID:Shoodey,项目名称:Events,代码行数:14,代码来源:RolesSeeder.php

示例5: index

 public function index()
 {
     $tab = 'dashboard';
     $users = User::get();
     $usersCount = $users->count();
     $activeUsers = $users->where('active', 1)->count();
     $inactiveUsers = $usersCount - $activeUsers;
     $roles = Role::get();
     $rolesCount = $roles->count();
     $usersWithRole = DB::table('role_user')->count();
     $permissionsCount = Permission::get()->count();
     return view('admin.dashboard', compact('tab', 'usersCount', 'activeUsers', 'inactiveUsers', 'rolesCount', 'usersWithRole', 'permissionsCount'));
 }
开发者ID:Shoodey,项目名称:Events,代码行数:13,代码来源:DashboardController.php

示例6: setUp

 /**
  * Default preparation for each test
  */
 public function setUp()
 {
     parent::setUp();
     // Fetch the admin user.
     $this->admin = User::whereAdmin()->with('roles')->with('roles.permissions')->take(1)->get()->first();
     // Fetch the admin role.
     $this->adminRole = Role::where('role_id', '=', Role::ID_ADMIN)->with('permissions')->first();
     // Fetch a board owner.
     $this->owner = User::whereOwner()->with('roles')->with('roles.permissions')->take(1)->get()->first();
     // Fetch the owner role.
     $this->ownerRole = $this->owner->roles->where('role', "owner")->first();
     // Fetch all permissions.
     $this->permissions = Permission::get();
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:17,代码来源:PermissionsTest.php

示例7:

@extends('admin.layout')

@section('form_footer')

    <?php 
$all_permissions_arr = \App\Permission::get();
if (!isset($role_permissions_ids_arr)) {
    $role_permissions_ids_arr = [];
}
?>

    <div class="form-group">
        <label>Привилегии</label> - <a href="/admin/permission">перейти к списку привилегий</a>
    @foreach($all_permissions_arr as $permission)
        <div class="checkbox">
            <label>
                <input type="checkbox" name="permissions[]" value="{{ $permission->id }}"{{ in_array($permission->id, $role_permissions_ids_arr) ? ' checked' : '' }}>
                {{ $permission->name }} - {{ $permission->display_name }}
            </label>
        </div>
    @endforeach
    </div>

@endsection

@section('content')
    @include('admin.common.edit_form', ['footer_content' => 'role_footer_content'])
@endsection
开发者ID:serovvitaly,项目名称:kotik,代码行数:28,代码来源:edit_form.blade.php

示例8: run

 public function run()
 {
     $this->command->info('Seeding permission to role associations.');
     // Insert default permissions.
     foreach ($this->slugs() as $slug) {
         RolePermission::firstOrCreate(['role_id' => $slug['role_id'], 'permission_id' => $slug['permission_id'], 'value' => $slug['value']]);
     }
     // Give admin permissions.
     $permissions = Permission::get();
     if (count($permissions)) {
         foreach ($permissions as $permission) {
             $permission = RolePermission::firstOrNew(['role_id' => Role::$ROLE_ADMIN, 'permission_id' => $permission->permission_id]);
             $permission->value = 1;
             $permission->save();
         }
     }
 }
开发者ID:ee-ee,项目名称:infinity-next,代码行数:17,代码来源:DatabaseSeeder.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $permissions = Permission::get();
     $tab = 'permissions';
     return view('admin.permissions.index', compact('permissions', 'tab'));
 }
开发者ID:Shoodey,项目名称:Events,代码行数:11,代码来源:PermissionsController.php

示例10: allPermissions

 public function allPermissions()
 {
     return Permission::get(['id', 'nombre', 'modulo']);
 }
开发者ID:herodez,项目名称:Deposito,代码行数:4,代码来源:rolesController.php

示例11: editRole

 public function editRole($id)
 {
     $role = Role::with('permissions')->findOrFail($id);
     $permissions = Permission::get(['id', 'name']);
     return view('admin.users.editrole', compact('role', 'permissions'));
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:6,代码来源:UserController.php

示例12: index

 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $permissions = Permission::get();
     return view('entrust.permissions.index', compact('permissions'));
 }
开发者ID:decalages,项目名称:ct-base,代码行数:10,代码来源:PermissionsController.php


注:本文中的app\Permission::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。