/** * Execute the job. * * @return void */ public function handle(StatusRepository $repository) { $status = Status::publish($this->body); $repository->save($status, $this->userId); event(new StatusWasPublished($status)); return $status; }
/** * 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()]); } }
/** * Get the feed for a user. * * @param User $user * @return mixed */ public function getFeedForUser(User $user) { $userIds = $user->fallowedUsers()->lists('fallowed_id'); $userIds[] = $user->id; return Status::with('comments')->whereIn('user_id', $userIds)->latest()->get(); }