natec1991

TimelineIndex

Aug 6th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Timeline\Http\Handlers;
  4.  
  5. use App\Jobs\Entities\Jobs;
  6. use App\Timeline\Entities\Timeline;
  7. use App\Timeline\Http\Responses\TimelineIndexResponse;
  8.  
  9. final class TimelineIndex
  10. {
  11.     /**
  12.      * @var \App\Timeline\Entities\Timeline
  13.      */
  14.     private $timeline;
  15.  
  16.     /**
  17.      * TimelineIndex constructor.
  18.      *
  19.      * @param \App\Timeline\Entities\Timeline $timeline
  20.      */
  21.     public function __construct(Timeline $timeline)
  22.     {
  23.         $this->timeline = $timeline;
  24.     }
  25.  
  26.     /**
  27.      * @return \App\Timeline\Http\Responses\TimelineIndexResponse
  28.      */
  29.     public function __invoke(): TimelineIndexResponse
  30.     {
  31.         $statuses = $this->timeline
  32.             ->with('owner')
  33.             ->friendsAndFollowers()
  34.             ->orderBy('timeline.created_at', 'desc')
  35.             ->paginate(10)
  36.             ->getCollection();
  37.  
  38.         return new TimelineIndexResponse($statuses);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment