/** * Handle the login command. * * @param \StyleCI\StyleCI\Commands\User\LoginCommand $command * * @return void */ public function handle(LoginCommand $command) { $user = User::find($command->id); $attributes = ['name' => $command->name, 'email' => $command->email, 'username' => $command->username, 'token' => $command->token]; if ($user) { $user->fill($attributes); } else { $user = new User(array_merge(['id' => $command->id], $attributes)); event(new UserHasSignedUpEvent($user)); } $user->save(); event(new UserHasLoggedInEvent($user)); }