Skip to content

Instantly share code, notes, and snippets.

@auniverseaway
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save auniverseaway/2ffb4799a6f05eaa997e to your computer and use it in GitHub Desktop.
Save auniverseaway/2ffb4799a6f05eaa997e to your computer and use it in GitHub Desktop.
API Controller
public function getRecentEpisodes()
{
$podcastid = Input::get('podcast_id');
$podcast = Podcast::find($podcastid);
$episode = Podcast::find($podcastid)->episodes()->first();
if(!$episode)
{
// If we don't have any epsisodes, we need to import them for the feed
App::make('EpisodesController')->importAllEpisodes($podcast);
}
else
{
// We should always import the latest episodes
App::make('EpisodesController')->importNewestEpisodes($podcast);
}
// Now let's collect our episodes
$episodes = App::make('EpisodesController')->getLastTenEpisodes($podcast);
$return = array(
'response' => $episodes
);
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment