mirror of
https://github.com/devfake/flox.git
synced 2024-11-15 14:42:31 +01:00
619e407bcd
* start with subpage design * transitions * transitions * transitions, stuff * modal for trailer * english fallback for trailers * slugs in url * bit refactor * tests and fixtures * travis * update production files * move time limit to config and display error message to user * fix import * fix review
34 lines
814 B
PHP
34 lines
814 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\Models\ItemService;
|
|
|
|
class Subpage {
|
|
|
|
private $itemService;
|
|
private $tmdb;
|
|
|
|
public function __construct(ItemService $itemService, TMDB $tmdb)
|
|
{
|
|
$this->itemService = $itemService;
|
|
$this->tmdb = $tmdb;
|
|
}
|
|
|
|
public function item($tmdbId, $mediaType)
|
|
{
|
|
if($found = $this->itemService->findBy('tmdb_id', $tmdbId)) {
|
|
return $found;
|
|
}
|
|
|
|
$found = $this->tmdb->details($tmdbId, $mediaType);
|
|
$found->genre_ids = collect($found->genres)->pluck('id')->all();
|
|
|
|
$item = $this->tmdb->createItem($found, $mediaType);
|
|
$item['youtube_key'] = $this->itemService->parseYoutubeKey($found, $mediaType);
|
|
$item['imdb_id'] = $this->itemService->parseImdbId($found);
|
|
|
|
return $item;
|
|
}
|
|
}
|