コード例 #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         User::create(['username' => $faker->word . $index, 'email' => $faker->email, 'password' => 'secret']);
     }
 }
コード例 #2
0
 public function handle($command)
 {
     $user = User::register($command->username, $command->email, $command->password);
     //dd($user);
     $this->repository->save($user);
     return $user;
 }
コード例 #3
0
 /**
  * Handle a command.
  *
  * @param $command
  * @return mixed
  */
 public function handle($command)
 {
     $user = User::register($command->username, $command->email, $command->password);
     $this->repository->save($user);
     $this->dispatcher->dispatch($user->releaseEvents());
     return $user;
 }
コード例 #4
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         User::create(['username' => $faker->word . $index, 'email' => $faker->word . $index . '@example.com', 'password' => 'password']);
     }
 }
コード例 #5
0
 public function run()
 {
     $faker = Faker::create();
     $userIds = User::lists('id');
     foreach (range(1, 1000) as $index) {
         Status::create(['user_id' => $faker->randomElement($userIds), 'body' => $faker->sentence(), 'created_at' => $faker->dateTime()]);
     }
 }
コード例 #6
0
 public function handle(UserRepository $repository)
 {
     $username = $this->username;
     $email = $this->email;
     $password = $this->password;
     $user = User::register($username, $email, $password);
     $repository->save($user);
     return $user;
 }
コード例 #7
0
 public function run()
 {
     $users = User::lists('id')->toArray();
     factory(Status::class, 1000)->make()->each(function (Status $s) use($users) {
         $s->user_id = $users[array_rand($users)];
         $s->created_at = mt_rand(time() - 365 * 24 * 60 * 60, time());
         $s->save();
     });
 }
コード例 #8
0
 /**
  * Handles the command
  *
  * @param Command $command Command
  *
  * @return User
  * @author Alonzo Tolver
  *
  **/
 public function handle($command)
 {
     /**
      * @var User
      */
     $user = User::register($command->username, $command->email, $command->password);
     $this->repository->save($user);
     $this->dispatchEventsFor($user);
     return $user;
 }
コード例 #9
0
 public function handle($command)
 {
     //register a user
     $user = User::register($command->username, $command->email, $command->password);
     //persist user in the db
     //$user->raise(new UserRegistered);
     $this->repository->save($user);
     //$events = $user->releaseEvents();
     $this->dispatchEventsFor($user);
     return $user;
 }
コード例 #10
0
ファイル: StatusRepository.php プロジェクト: akthaw/larabook
 public function leaveComment($userId, $statusId, $body)
 {
     $comment = Comment::leave($body, $statusId);
     User::findOrFail($userId)->comments()->save($comment);
     return $comment;
 }
コード例 #11
0
 public function save(Comment $comment, User $user)
 {
     return $user->comments()->save($comment);
 }
コード例 #12
0
 /**
  * Get the feed for the user
  *
  */
 public function getFeedForUser(User $user)
 {
     $userIds = $user->followedUsers()->lists('followed_id');
     $userIds[] = $user->id;
     return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get();
 }
コード例 #13
0
 /**
  * Save a new status for a user
  *
  * @param Status $status
  * @param $userId
  * @return mixed
  */
 public function save(Status $status, $userId)
 {
     return User::findOrFail($userId)->statuses()->save($status);
 }
コード例 #14
0
 /**
  * Unfollow a Larabook user
  */
 public function unfollow($userIdToUnfollow, User $user)
 {
     return $user->followedUsers()->detach($userIdToUnfollow);
 }
コード例 #15
0
 public function getAllForUser(User $user)
 {
     return $user->statuses()->with('user')->latest()->get();
 }