create image upload endpoint create product creation endpoint create get product categories endpoint
29 lines
603 B
PHP
29 lines
603 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = [
|
|
'title',
|
|
'actual_price',
|
|
'list_price',
|
|
'description',
|
|
'product_category_id',
|
|
];
|
|
|
|
public function productCategory(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductCategory::class);
|
|
}
|
|
|
|
public function images(): HasMany
|
|
{
|
|
return $this->hasMany(ProductImage::class, 'product_id', 'id');
|
|
}
|
|
}
|