1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/backend/app/Services/Subpage.php
Viktor Geringer 619e407bcd subpage design (#64)
* 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
2017-04-11 08:45:08 +02:00

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;
}
}