27 lines
597 B
PHP
27 lines
597 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class GameVideo extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = ['game_id', 'igdb_id', 'name', 'video_id'];
|
||
|
|
|
||
|
|
public function game(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Game::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getYoutubeUrlAttribute(): string
|
||
|
|
{
|
||
|
|
return "https://www.youtube.com/watch?v={$this->video_id}";
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getYoutubeEmbedUrlAttribute(): string
|
||
|
|
{
|
||
|
|
return "https://www.youtube.com/embed/{$this->video_id}";
|
||
|
|
}
|
||
|
|
}
|