mirror of
https://github.com/devfake/flox.git
synced 2024-11-15 22:52:32 +01:00
5818026f67
* change parser fixtures * move alternativeTitle method to other class * refactor tests * start with alternative title * use app helper method * refactor add items * change fixtures structure * alternative title * episode service * item service * file parser test * flatten item controller * git ignorecase
42 lines
758 B
PHP
42 lines
758 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);
|
|
}
|
|
}
|