30 lines
671 B
PHP
30 lines
671 B
PHP
<?php
|
|
|
|
namespace Modules\Sites\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
final class SiteContent extends Model
|
|
{
|
|
protected $table = 'site_content';
|
|
|
|
protected $fillable = ['site_id', 'content_type', 'content_id', 'is_primary'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['is_primary' => 'boolean'];
|
|
}
|
|
|
|
public function site(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Site::class);
|
|
}
|
|
|
|
public function content(): MorphTo
|
|
{
|
|
return $this->morphTo(__FUNCTION__, 'content_type', 'content_id');
|
|
}
|
|
}
|