2023-06-21 09:53:21 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
class Episode extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
protected $dates = ['episode_date', 'created_at', 'updated_at', 'deleted_at'];
|
|
|
|
|
2023-12-14 12:33:03 -05:00
|
|
|
protected $casts = [
|
|
|
|
'episode_date' => 'date',
|
|
|
|
'created_at' => 'datetime',
|
|
|
|
'updated_at' => 'datetime',
|
|
|
|
'deleted_at' => 'datetime',
|
|
|
|
];
|
|
|
|
|
2023-06-21 09:53:21 -04:00
|
|
|
public function podcast()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Podcast::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function artwork()
|
|
|
|
{
|
2023-12-14 12:33:03 -05:00
|
|
|
return $this->hasOne(Artwork::class, 'id', 'artwork_id');
|
|
|
|
}
|
|
|
|
|
2024-01-13 12:30:38 -05:00
|
|
|
public function approvedArtworks()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Artwork::class)->whereNotNull('artworks.approved_by');
|
|
|
|
}
|
|
|
|
|
2023-12-14 12:33:03 -05:00
|
|
|
public function artworks()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Artwork::class);
|
2023-06-21 09:53:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function artist()
|
|
|
|
{
|
|
|
|
return $this->hasOneThrough(Artist::class, Artwork::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|