- implement DTO for product and modify productImageDTO. - add products resources and collection.
29 lines
619 B
PHP
29 lines
619 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 category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductCategory::class, 'product_category_id');
|
|
}
|
|
|
|
public function images(): HasMany
|
|
{
|
|
return $this->hasMany(ProductImage::class, 'product_id', 'id');
|
|
}
|
|
}
|