mirror of
https://github.com/devfake/flox.git
synced 2024-11-15 22:52:32 +01:00
7d7553088c
* move to local scope * start file parser * flatten controller * update tests * composer update * Update tests, include episodes * store src for tv episodes * simplify fixtures * refactor * refactor episode and alternative title * refactor item category * fix typo and remove exception
33 lines
699 B
PHP
33 lines
699 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use App\Services\TMDB;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AlternativeTitle extends Model {
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = ['title', 'tmdb_id', 'country'];
|
|
|
|
/**
|
|
* Store all alternative titles for tv shows and movies.
|
|
*
|
|
* @param $item
|
|
* @param TMDB $tmdb
|
|
*/
|
|
public function store($item, TMDB $tmdb)
|
|
{
|
|
$alternativeTitles = $tmdb->getAlternativeTitles($item);
|
|
|
|
foreach($alternativeTitles as $title) {
|
|
$this->firstOrCreate([
|
|
'title' => $title->title,
|
|
'tmdb_id' => $item['tmdb_id'],
|
|
'country' => $title->iso_3166_1,
|
|
]);
|
|
}
|
|
}
|
|
}
|