/** * Run the database seeds. * * @return void */ public function run() { $garbleUser = User::where('name', 'gable')->get()->first(); //New Install or being seeder being run for another time. if (empty($garbleUser) && empty(User::first())) { $userInfo = ['name' => 'Garble Admin', 'username' => 'garble', 'password' => Hash::make(env('APP_KEY'))]; /** @var User $user */ $user = factory(User::class)->create($userInfo)->save(); // $user->assignRole('admin'); } }
public function before(User $user) { if ($user->isAdmin()) { return true; } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'username' => $data['username'], 'password' => bcrypt($data['password'])]); }