<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Product extends Model
{
    protected $fillable = [
        'name',
        'description',
        'created_by',
        'exclude_from_sales',
        'is_deleted',
        'created_at',
        'updated_at',
        'deleted_at',
    ];

    protected $casts = [
        'exclude_from_sales' => 'boolean',
        'is_deleted' => 'boolean',
    ];

    public function leads_service(): HasMany
    {
        return $this->hasMany(LeadService::class);
    }

    public function quotation(): HasMany
    {
        return $this->hasMany(QuotationDetail::class);
    }

    public function lead_sale(): HasMany
    {
        return $this->hasMany(LeadSale::class);
    }

    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function task_products(): HasMany
    {
        return $this->hasMany(TaskProduct::class);
    }
}
