feat: Many category and Many sub-category media

This commit is contained in:
2026-05-31 20:18:53 +03:30
parent 56f0e8dbe2
commit 449a542571
6 changed files with 190 additions and 48 deletions
+4 -6
View File
@@ -13,8 +13,6 @@ class Media extends Model
protected $fillable = [
'user_id',
'image_id',
'category_id',
'subcategory_id',
'title',
'caption',
'type',
@@ -45,14 +43,14 @@ public function image()
return $this->belongsTo(Image::class);
}
public function category()
public function categories()
{
return $this->belongsTo(Category::class);
return $this->belongsToMany(Category::class, 'category_media');
}
public function subCategory()
public function subCategories()
{
return $this->belongsTo(SubCategory::class, 'subcategory_id');
return $this->belongsToMany(SubCategory::class, 'media_sub_category');
}
public function tags()
{