/** * @param Requests\SignUpRequest $request * @param CommandDispatcher $commandDispatcher * * @return */ public function store(Requests\SignUpRequest $request, CommandDispatcher $commandDispatcher) { $commandDispatcher->dispatchFrom(RegisterUser::class, $request); \Auth::login(User::where('username', $request['username'])->first()); Flash::overlay('Welcome!!'); return Redirect::home(); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); foreach (range(0, 50) as $index) { \App\Users\User::create(['username' => $faker->userName . $index, 'email' => $faker->email, 'password' => 'secret']); } }
public function leaveComment(Comment $comment) { $userId = $comment->user_id; $comment = Comment::leave($comment); User::findOrFail($userId)->comments()->save($comment); return $comment; }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); $userIds = \App\Users\User::lists('id')->toArray(); foreach (range(0, 500) as $index) { Status::create(['user_id' => $faker->randomElement($userIds), 'body' => $faker->sentence(), 'created_at' => $faker->dateTime()]); } }
/** * 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'])]); }
/** * Determine if the current user fallows other user * * @param User $otherUser * @return bool */ public function isFallowedBy(User $otherUser) { $idsWhoOtherUserFallows = $otherUser->fallowedUsers()->lists('fallowed_id'); return in_array($this->id, $idsWhoOtherUserFallows->toArray()); }
/** * Execute the job. * @param User $userModel * @param UserRepository $repository * @param Dispatcher $dispatcher */ public function handle(User $userModel, UserRepository $repository, Dispatcher $dispatcher) { $user = $userModel->register($this->username, $this->email, $this->password); $dispatcher->fire(new UserRegistered($user)); $repository->save($user); }