コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * 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']);
     }
 }
コード例 #3
0
 public function leaveComment(Comment $comment)
 {
     $userId = $comment->user_id;
     $comment = Comment::leave($comment);
     User::findOrFail($userId)->comments()->save($comment);
     return $comment;
 }
コード例 #4
0
 /**
  * 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()]);
     }
 }
コード例 #5
0
 /**
  * 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'])]);
 }
コード例 #6
0
 /**
  * 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());
 }
コード例 #7
0
 /**
  * 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);
 }