pai-sklep/app/Models/Product.php

29 lines
568 B
PHP
Raw Normal View History

2021-09-05 02:22:17 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
2021-11-14 14:51:49 +01:00
use HasFactory;
use HasUUID;
2021-10-28 11:19:42 +02:00
public $primaryKey = "uuid";
2021-12-08 23:39:53 +01:00
public function images() {
2021-12-08 21:29:28 +01:00
return $this->morphMany(Image::class, 'imageable');
2021-11-14 20:44:10 +01:00
}
2021-11-14 14:51:49 +01:00
2021-12-08 23:39:53 +01:00
public function categories() {
return $this->belongsToMany(Category::class,'categories_products','product_uuid');
}
2021-09-05 02:22:17 +02:00
protected $fillable = [
'name',
'description',
2021-12-08 18:25:48 +01:00
'images',
'price'
2021-09-05 02:22:17 +02:00
];
}