pai-sklep/app/Models/Category.php

24 lines
493 B
PHP
Raw Permalink Normal View History

2021-12-08 23:39:53 +01:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
2021-12-16 11:51:47 +01:00
use HasFactory;
use HasUUID;
2021-12-08 23:39:53 +01:00
public $primaryKey = "uuid";
protected $fillable = ['name'];
public function products() {
2021-12-09 12:13:11 +01:00
return $this->belongsToMany(Product::class,'categories_products','category_uuid');
2021-12-08 23:39:53 +01:00
}
public function image() {
return $this->morphOne(Image::class, 'imageable');
}
}