belongsTo(ProductCategory::class, 'product_category_id'); } public function images(): HasMany { return $this->hasMany(ProductImage::class, 'product_id', 'id'); } protected static function booted(): void { static::saving(function ($product) { if (empty($product->slug) || $product->isDirty('title')) { $product->slug = Str::slug($product->title); } }); } }