public function updateOngoing()
 {
     return $this->execute(function () {
         $series = Anime::where('status', 1)->where('updated_at', '<', \Carbon\Carbon::today()->subDay())->get(array('mal_id', 'hum_id', 'name'));
         if (count($series) > 0) {
             $scraper = new AnimeDataScraper();
             $r = '';
             foreach ($series as $serie) {
                 $result = $scraper->get($serie->mal_id, str_replace(' ', '+', $serie->name), $serie->hum_id);
                 if (!empty($result)) {
                     $scraper->save($result);
                     $r .= 'Succesfully! - ' . $serie->name . '<br/>';
                 } else {
                     $r .= 'Failed! - ' . $serie->name . '<br/>';
                 }
             }
             return $r;
         }
         return 'No updateable ONGOING anime found!';
     });
 }
Esempio n. 2
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    return View::make('index');
});
Route::group(['prefix' => 'api'], function () {
    Route::get('/anime', function () {
        $data = Anime::get();
        return $data;
    });
    Route::get('/anime/{anime}/{episode}', function ($animeslug, $episodeslug) {
        $anime = Anime::where('slug', $animeslug)->first();
        $episode = Episode::where('episodeNum', $episodeslug)->where('anime_id', $anime->id)->first();
        return ["episode" => $episode, "anime" => $anime];
    });
    Route::get('/anime/{slug}', function ($slug) {
        //$data = Anime::where('slug', $slug)->first();
        $data = Anime::with('episodes')->where('slug', $slug)->first();
        return $data;
    });
});