Exemple #1
0
 public function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $user->attachRole($data['role']);
     $user->attachPermission($data['permission']);
     return $user;
 }
 public function run()
 {
     $users = User::all();
     $roles = Role::all();
     foreach ($users as $user) {
         $user->attachRole($roles[rand(0, count($roles) - 1)]);
     }
 }
 public function run()
 {
     $users = User::all();
     $permissions = Permission::all();
     foreach ($users as $user) {
         $user->attachPermission($permissions[rand(0, count($permissions) - 1)]);
     }
 }