<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Product extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'name',
        'category',
        'brand',
        'description',
        'price',
        'old_price',
        'stock',
        'image_path',
        'is_new',
        'rating',
        'num_reviews',
    ];

    protected $casts = [
        'price'     => 'float',
        'old_price' => 'float',
        'is_new'    => 'boolean',
        'rating'    => 'float',
    ];

    public function orderItems()
    {
        return $this->hasMany(OrderItem::class);
    }
}
