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