23 lines
486 B
PHP
23 lines
486 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
class Category extends Model
|
||
|
{
|
||
|
use HasFactory, HasUUID;
|
||
|
public $primaryKey = "uuid";
|
||
|
|
||
|
protected $fillable = ['name'];
|
||
|
|
||
|
public function products() {
|
||
|
return $this->belongsToMany(Category::class,'categories_products','category_uuid');
|
||
|
}
|
||
|
|
||
|
public function image() {
|
||
|
return $this->morphOne(Image::class, 'imageable');
|
||
|
}
|
||
|
}
|