/** * Handle the command * * @param $command * @return static */ public function handle($command) { $status = Status::publish($command->body); $this->statusRepository->save($status, $command->userId); $this->dispatchEventsFor($status); return $status; }
/** * Handle a command. * * @param $command * @return mixed */ public function handle($command) { $status = Status::publish($command->body); $this->repository->save($status, $command->user_id); $this->dispatcher->dispatch($status->releaseEvents()); return $status; }
/** * Execute the job. * * @param StatusRepository $repository * @return static */ public function handle(StatusRepository $repository) { $body = $this->body; $status = Status::publish(compact('body')); $status = $repository->save($status); return $status; }
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()]); } }
/** * Handle the command * * @param $command * @return mixed */ public function handle($command) { //publish status $status = Status::publish($command->body); //persist status in the db $status = $this->statusRepository->save($status, $command->userId); $this->dispatchEventsFor($status); return $status; }
/** * Get the feed for a user. * * @param User $user * @return mixed */ public function getFeedForUser(User $user) { $userIds = $user->followedUsers()->lists('followed_id'); $userIds[] = $user->id; return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get(); }