25 lines
561 B
PHP
25 lines
561 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class SubCategory extends Model
|
|
{
|
|
protected $table = 'sub_categories';
|
|
|
|
protected $fillable = ['category_id', 'name', 'description'];
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
public function media(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Media::class, 'media_sub_category');
|
|
}
|
|
}
|