Blame view
app/Http/ViewComposers/PostsGridComposer.php
1.37 KB
e77200db5 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?php namespace FootyRoom\Http\ViewComposers; use FootyRoom\Http\Match\MatchSlug; use Illuminate\Contracts\View\View; use FootyRoom\Queries\Post\MatchPost; class PostsGridComposer { /** * Compose the view. * * @param \Illuminate\Contracts\View\View $view * @param \FootyRoom\Queries\Post\Post[] $posts * @param int $page * @param bool $legendary * * @return \Illuminate\Contracts\View\View */ public function compose(View $view, $posts, $page, $legendary = false) { foreach ($posts as $post) { if (!isset($post->url) && $post instanceof MatchPost) { $post->url = route('matchReview', [ 'id' => $post->matchId, 'slug' => MatchSlug::fromTeams($post->homeTeamName, $post->awayTeamName), ]); } if ($post instanceof MatchPost) { $post->titleNoSpoilers = "{$post->homeTeamName} vs {$post->awayTeamName}"; $post->date = $post->matchDate; } if ($legendary) { $post->date = $post->matchDate; } if ($post->sticky > 0) { $post->date = 'Sticky'; } } $view->with('page', $page); $view->with('posts', $posts); $view->with('legendary', $legendary); return $view; } } |