/home/bdqbpbxa/dev-subdomains/api-uniferx.goodface.com.ua/app/Models/Catalog.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
class Catalog extends Model
{
use HasFactory;
protected $table = 'catalogs';
protected $fillable = [
'system_name',
'title',
'type',
'image',
'description',
'file',
'is_enabled',
];
protected $casts = [
'image' => 'array',
'file' => 'array',
];
public function flyers(): MorphToMany
{
return $this->morphToMany(Flyer::class, 'flyerables');
}
public function products()
{
return $this->morphedByMany(Product::class, 'catalogables');
}
}