ekart/backend/app/Models/Product.php
kusowl 920666c201 feature: add index endpoint for products
- implement DTO for product and modify productImageDTO.
- add products resources and collection.
2026-02-27 18:16:02 +05:30

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');
}
}