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


PHP Role::truncate方法代碼示例

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


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

示例1: 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

示例2: tearDown

 public function tearDown()
 {
     Mockery::close();
     User::truncate();
     Book::truncate();
     Item::truncate();
     Role::truncate();
     Client::truncate();
     Group::truncate();
     Photo::truncate();
 }
開發者ID:reverserob,項目名稱:laravel-mongodb,代碼行數:11,代碼來源:EmbeddedRelationsTest.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     Role::truncate();
     Role::create(['name' => 'Admin']);
     Role::create(['name' => 'Moderator']);
     Role::create(['name' => 'User']);
     DB::table('role_user')->truncate();
     //		$john = User::find(1);
     //
     //		$john->roles()->attach(1);
 }
開發者ID:SenhorBardell,項目名稱:yol,代碼行數:12,代碼來源:RolesTableSeeder.php

示例4: run

 public function run()
 {
     Role::truncate();
     $adminRole = new Role();
     $adminRole->name = 'admin';
     $adminRole->save();
     $resellerRole = new Role();
     $resellerRole->name = 'reseller';
     $resellerRole->save();
     $clientRole = new Role();
     $clientRole->name = 'user';
     $clientRole->save();
     $subscriberRole = new Role();
     $subscriberRole->name = 'subscriber';
     $subscriberRole->save();
     $user = User::where('username', '=', 'admin')->first();
     $user->attachRole($adminRole);
     $user = User::where('username', '=', 'user')->first();
     $user->attachRole($clientRole);
     $user = User::where('username', '=', 'user2')->first();
     $user->attachRole($clientRole);
 }
開發者ID:mladjom,項目名稱:smartinvoice,代碼行數:22,代碼來源:RolesTableSeeder.php

示例5: generateRoles

 public function generateRoles()
 {
     Role::truncate();
     Role::create(array('name' => 'admin'));
     Role::create(array('name' => 'member'));
 }
開發者ID:kcsamita,項目名稱:laravelsnippets,代碼行數:6,代碼來源:TestCase.php


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