feat: Many category and Many sub-category media
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user