/** * @return User */ public function getTestUser() { if (self::$user instanceof User) { return self::$user; } return self::$user = User::find(1); }
/** * Execute the console command. * * @return mixed */ public function fire() { $userData = []; $userData['email'] = $this->ask('What is the email for the user?'); $userData['first_name'] = $this->ask('First name?'); $userData['last_name'] = $this->ask('Last name?'); $userData['display_name'] = $this->ask('Display name?'); $userData['password'] = $this->secret('What is the password for the user?'); $userData['password_confirmation'] = $this->secret('Confirm password'); $validator = Validator::make($userData, User::$rules); if ($validator->fails()) { $messages = $validator->errors()->getMessages(); foreach ($messages as $message) { if (isset($message[0])) { $this->error($message[0]); echo "\n"; } } $this->info('Try running ' . $this->name . ' again.'); } else { if (count(User::all()) == 0) { $userData['owner'] = true; } $userData['password'] = Hash::make($userData['password']); User::create($userData); $this->info("User created."); } }
public function run() { $userData = []; $userData['email'] = '*****@*****.**'; $userData['first_name'] = 'Test'; $userData['last_name'] = 'User'; $userData['display_name'] = 'test_user'; $userData['password'] = Hash::make(ENV('APP_KEY', 'password')); $userData['owner'] = true; User::create($userData); }
public function update(array $attributes = []) { //There's one user and they're not the owner of the site yet. //Or the owner is giving ownership to another user. if (array_key_exists('owner', $attributes)) { if (count(User::all()) == 1 && $this->owner == 0 || $this->owner) { $attributes['owner'] = true; } else { $attributes['owner'] = false; } } else { if ($this->owner) { $attributes['owner'] = true; } else { $attributes['owner'] = false; } } parent::update($attributes); }
/** * 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'], 'password' => bcrypt($data['password'])]); }
/** * Remove the specified user from storage. * * @param int $id * * @return Response */ public function destroy($id) { User::destroy($id); return redirect()->route('admin.users.index'); }