Exemplo n.º 1
0
 /**
  * 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;
 }
 /** @test */
 public function it_saves_a_status_for_a_specific_user()
 {
     // Given I have unsaved status
     $status = Factory::build(Status::class, ['user_id' => null, 'body' => 'My Status']);
     // And an existing user
     $user = Factory::create(User::class);
     // When I try to persist this status
     $savedStatus = $this->repo->save($status, $user);
     // Then it should be saved
     $this->tester->seeRecord('statuses', ['body' => 'My Status']);
     // And the status should have the correct user_id
     $this->assertEquals($user->id, $savedStatus->user_id);
 }
Exemplo n.º 3
0
 /**
  * Execute the job.
  *
  * @param Status $status
  * @param Dispatcher $event
  * @param StatusRepository $statusRepository
  */
 public function handle(Status $status, Dispatcher $event, StatusRepository $statusRepository)
 {
     $status = $status->publish($this->body, $event);
     $statusRepository->save($status, $this->user);
 }
Exemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(StatusRepository $repository)
 {
     $statuses = $repository->getAllForUser(Auth::user());
     return view('statuses.index', compact('statuses'));
 }
 /**
  * Execute the job.
  *
  * @param StatusRepository $statusRepository
  */
 public function handle(StatusRepository $statusRepository)
 {
     $comment = new Comment(['user_id' => $this->userId, 'status_id' => $this->statusId, 'body' => $this->body]);
     $statusRepository->leaveComment($comment);
 }