Example #1
0
function getOneFetch($theFetch, $table)
{
    $row = $theFetch->fetch();
    $return = array();
    if ($table == "anime") {
        //If the search is on the "anime" table
        $return = getAnime($row);
        if ($row['site_streaming_anime']) {
            $return['site_streaming_anime'] = "<a href=\"" . $row['site_streaming_anime'] . "\">Go to streaming</a>";
        } else {
            $return['site_streaming_anime'] = "<font color=\"red\">No site in the DataBase<font/>";
        }
    } else {
        if ($table == "characters") {
            //If the search is on the "personnage" table
            $return = getChara($row);
        } else {
            if ($table == "oav_anime") {
                //If the search is on the "oav_anime" table
                $return = array("id_oav" => $row['id_oav'], "id_anime" => $row['id_anime'], "nom_oav" => $row['nom_oav'], "type_oav" => $row['type_oav'], "site_streaming_oav" => $row['site_streaming_oav']);
                if ($return['site_streaming_oav']) {
                    //If a site is in the DB
                    $return['site_streaming_oav'] = "<a href=\"" . $row['site_streaming_oav'] . "\">Go to streaming</a>";
                } else {
                    $return['site_streaming_oav'] = "<font color=\"red\">No site in the DataBase<font/>";
                }
            } else {
                echo "Unknown table; problem in code page...";
            }
        }
    }
    return $return;
}
    foreach ($series as $serie) {
        $latest = DB::table('latest_anime')->whereRaw('anime_id = ?', array($serie->id))->select('created_at', 'episode')->orderBy('created_at', 'DESC')->first();
        if (!empty($latest)) {
            $today = new DateTime();
            $future = new DateTime($latest->created_at);
            $future->add(new DateInterval("PT168H"));
            $interval = $future->diff($today);
            if ($future > $today) {
                $date = $interval->format('%d%H');
                array_push($anime, array('episode' => $latest->episode, 'interval' => $interval, 'anime' => $serie, 'sort' => $date));
            }
        }
    }
    return $anime;
}
$series = getAnime();
usort($series, function ($a1, $a2) {
    return $a1["sort"] < $a2["sort"] ? -1 : 1;
});
$count = 0;
$total_count = 0;
$total = count($series);
foreach ($series as $serie) {
    $time = '';
    if ($serie["interval"]->d > 0) {
        $time .= $serie["interval"]->d . 'days ';
    }
    $time .= $serie["interval"]->h . 'hrs ' . $serie["interval"]->i . 'mins ';
    echo View::make('child.card_anime', array("anime_id" => $serie["anime"]->id, "anime_name" => $serie["anime"]->name, "anime_episode" => (int) $serie["episode"] + 1, "anime_img" => Anime::getCover($serie["anime"]), "time" => $time, "display" => "chart"));
}
?>