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


PHP Permission::truncate方法代碼示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     Permission::truncate();
     DB::table('permission_role')->truncate();
     Permission::create(['action' => 'User.create']);
     Permission::create(['action' => 'User.view']);
     Permission::create(['action' => 'User.update']);
     Permission::create(['action' => 'User.delete']);
     Permission::create(['action' => 'Category.create']);
     Permission::create(['action' => 'Category.view']);
     Permission::create(['action' => 'Category.update']);
     Permission::create(['action' => 'Category.delete']);
     Permission::create(['action' => 'Post.create']);
     Permission::create(['action' => 'Post.view']);
     Permission::create(['action' => 'Post.update']);
     Permission::create(['action' => 'Post.delete']);
     Permission::create(['action' => 'Comment.create']);
     Permission::create(['action' => 'Comment.view']);
     Permission::create(['action' => 'Comment.update']);
     Permission::create(['action' => 'Comment.delete']);
     Permission::create(['action' => 'Role.create']);
     Permission::create(['action' => 'Role.view']);
     Permission::create(['action' => 'Role.update']);
     Permission::create(['action' => 'Role.delete']);
     Permission::create(['action' => 'Permission.create']);
     Permission::create(['action' => 'Permission.view']);
     Permission::create(['action' => 'Permission.update']);
     Permission::create(['action' => 'Permission.delete']);
     $admin = Role::find(1);
     $admin->permissions()->sync(range(1, 24));
 }
開發者ID:SenhorBardell,項目名稱:yol,代碼行數:32,代碼來源:PermissionsTableSeeder.php

示例2: run

 public function run()
 {
     /**
      * Truncate Tables
      */
     Permission::truncate();
     Role::truncate();
     User::truncate();
     DB::table('assigned_roles')->truncate();
     DB::table('permission_role')->truncate();
     /**
      * Seed Datas
      */
     $permissions = [['name' => 'Role:list', 'display_name' => 'List Roles', 'group_name' => 'Role'], ['name' => 'Role:show', 'display_name' => 'Show Role', 'group_name' => 'Role'], ['name' => 'Role:create', 'display_name' => 'Create New Role', 'group_name' => 'Role'], ['name' => 'Role:edit', 'display_name' => 'Edit Existing Role', 'group_name' => 'Role'], ['name' => 'Role:delete', 'display_name' => 'Delete Existing Role', 'group_name' => 'Role'], ['name' => 'Permission:list', 'display_name' => 'List Permissions', 'group_name' => 'Permission'], ['name' => 'Permission:show', 'display_name' => 'Show Permission', 'group_name' => 'Permission'], ['name' => 'Permission:create', 'display_name' => 'Create New Permission', 'group_name' => 'Permission'], ['name' => 'Permission:edit', 'display_name' => 'Edit Existing Permission', 'group_name' => 'Permission'], ['name' => 'Permission:delete', 'display_name' => 'Delete Existing Permission', 'group_name' => 'Permission'], ['name' => 'User:list', 'display_name' => 'List Users', 'group_name' => 'Users'], ['name' => 'User:show', 'display_name' => 'Show User', 'group_name' => 'Users'], ['name' => 'User:create', 'display_name' => 'Create New User', 'group_name' => 'Users'], ['name' => 'User:edit', 'display_name' => 'Edit Existing User', 'group_name' => 'Users'], ['name' => 'User:delete', 'display_name' => 'Delete Existing User', 'group_name' => 'Users'], ['name' => 'User:set_confirmation', 'display_name' => 'Set Existing User\'s Confirmed Status', 'group_name' => 'Users'], ['name' => 'User:set_password', 'display_name' => 'Set Existing User\'s Password', 'group_name' => 'Users']];
     $roles = [['name' => 'Admin'], ['name' => 'Role Admin'], ['name' => 'Permission Admin'], ['name' => 'User Admin'], ['name' => 'User'], ['name' => 'Upload Admin']];
     $users = [['first_name' => 'System', 'last_name' => 'Administrator', 'username' => 'admin', 'email' => 'admin@example.com', 'password' => 'admin', 'password_confirmation' => 'admin', 'confirmed' => 1], ['first_name' => 'System', 'last_name' => 'User', 'username' => 'user', 'email' => 'user@example.com', 'password' => 'user', 'password_confirmation' => 'user', 'confirmed' => 1]];
     $user_roles = [1 => [1], 2 => [6]];
     /**
      * Insert Into DB
      */
     foreach ($permissions as $data) {
         Permission::create($data);
     }
     foreach ($roles as $data) {
         Role::create($data);
     }
     foreach ($users as $data) {
         $user = User::create($data);
         if (isset($user_roles[$user->id])) {
             $user->roles()->sync($user_roles[$user->id]);
         }
     }
 }
開發者ID:k4ml,項目名稱:laravel-base,代碼行數:33,代碼來源:LaravelBaseSeeder.php

示例3: postSavePermissions

 public function postSavePermissions(Request $request)
 {
     //return $request->all();
     $permissions = $request->get('permissions');
     Permission::truncate();
     foreach ($permissions as $role => $perms) {
         foreach ($perms as $perm) {
             $permission = new Permission();
             $permission->roles_id = Role::where('name', $role)->first()->id;
             $permission->route = $perm;
             $permission->save();
         }
     }
     return back();
 }
開發者ID:tanmuhittin,項目名稱:rolemanager,代碼行數:15,代碼來源:RoleController.php


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