public function run()
 {
     // !!! All existing roles are deleted !!!
     DB::table('role_user')->truncate();
     DB::table('roles')->truncate();
     $user = User::where('email', '*****@*****.**')->firstOrFail();
     $roleAdmin = Role::create(['name' => 'admin']);
     $user->roles()->attach($roleAdmin->id);
 }
 public function testRenderIndexIfHaveReadAbilityOnUser()
 {
     $admin = User::where('name', 'Administrator')->firstOrFail();
     if (!$admin->hasRole('admin')) {
         $roleAdmin = Role::firstOrCreate(['name' => 'admin']);
         $admin->roles()->attach($roleAdmin->id);
     }
     $this->loginAs($admin);
     $response = $this->action('GET', "UsersController@index");
     $view = $response->original;
     $this->assertEquals($view->getName(), 'users.index');
     $this->assertViewHas('users');
 }
Пример #3
0
 public function destroy($id)
 {
     $role = Role::findOrFail($id);
     $role->delete();
     return;
 }