Last active
August 29, 2015 14:04
-
-
Save auniverseaway/2ffb4799a6f05eaa997e to your computer and use it in GitHub Desktop.
API Controller
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
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