feat: Many category and Many sub-category media
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class SubCategory extends Model
|
||||
{
|
||||
@@ -17,8 +17,8 @@ public function category(): BelongsTo
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function media(): HasMany
|
||||
public function media(): BelongsToMany
|
||||
{
|
||||
return $this->hasMany(Media::class, 'subcategory_id');
|
||||
return $this->belongsToMany(Media::class, 'media_sub_category');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user