Last active
August 29, 2015 14:16
-
-
Save ryanmr/4b0385073ebdfcd23a4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/{series_slug}/feed/fringe/', function($series_slug){ | |
$series = \App\Series::visible() | |
->where('slug', '=', $series_slug) | |
->firstOrFail(); | |
$episodes = \App\Episode | |
::with(['related']) | |
->visible() | |
->recent() | |
->withSlug($series_slug) | |
->take(50) | |
->get(); | |
$included_ids = array(); | |
foreach ($episodes as $episode) { | |
$included_ids[] = $episode->id; | |
if ( $episode->related->count() > 0 ) { | |
foreach ($episode->related as $related) { | |
if ( $related->pivot->type == 'fringe' ) { | |
$included_ids[] = $related->id; | |
} | |
} | |
} | |
} | |
$episodes = \App\Episode | |
::with('related') | |
->visible() | |
->recent() | |
->whereIn('id', $included_ids) | |
->take(50) | |
->get(); | |
// return dump($episodes); | |
return view('feed-series', [ | |
'series' => $series, | |
'episodes' => $episodes | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment