1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/backend/app/AlternativeTitle.php
Viktor Geringer a282723e1d remove status (#29)
* prepare fixtures

* refactor fileparser and add removed status

* update fileparser tests
2017-02-13 21:17:33 +01:00

43 lines
759 B
PHP

<?php
namespace App;
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 $titles
* @param $tmdbId
*/
public function store($titles, $tmdbId)
{
foreach($titles as $title) {
$this->firstOrCreate([
'title' => $title->title,
'tmdb_id' => $tmdbId,
'country' => $title->iso_3166_1,
]);
}
}
/*
* Scopes
*/
public function scopeFindByTmdbId($query, $tmdbId)
{
return $query->where('tmdb_id', $tmdbId);
}
}