2016-12-17 16:59:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
2017-01-06 09:40:27 +01:00
|
|
|
use App\Services\TMDB;
|
2016-12-17 16:59:59 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class AlternativeTitle extends Model {
|
|
|
|
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
protected $fillable = ['title', 'tmdb_id', 'country'];
|
2017-01-06 09:40:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2016-12-17 16:59:59 +01:00
|
|
|
}
|