public function run() { $faker = Faker::create(); foreach (range(1, 50) as $index) { User::create(['username' => $faker->word . $index, 'email' => $faker->email, 'password' => 'secret']); } }
public function handle($command) { $user = User::register($command->username, $command->email, $command->password); //dd($user); $this->repository->save($user); return $user; }
/** * 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; }
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']); } }
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()]); } }
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; }
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(); }); }
/** * 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; }
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; }
public function leaveComment($userId, $statusId, $body) { $comment = Comment::leave($body, $statusId); User::findOrFail($userId)->comments()->save($comment); return $comment; }
public function save(Comment $comment, User $user) { return $user->comments()->save($comment); }
/** * 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(); }
/** * 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); }
/** * Unfollow a Larabook user */ public function unfollow($userIdToUnfollow, User $user) { return $user->followedUsers()->detach($userIdToUnfollow); }
public function getAllForUser(User $user) { return $user->statuses()->with('user')->latest()->get(); }