<?php

namespace App\Models;

use App\Enums\ProductType;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use HasUuids, HasFactory;

    protected $guarded = [];

    protected $casts = [
        'product_type' => ProductType::class,
        'custom_data' => 'array',
        'infrastructure_status' => 'array',
        'area' => 'decimal:2',
        'price_per_unit' => 'decimal:2',
        'total_price' => 'decimal:2',
        'building_density' => 'decimal:2',
    ];

    public function project()
    {
        return $this->belongsTo(Project::class);
    }

    public function contracts()
    {
        return $this->hasMany(Contract::class);
    }

    public function settlements()
    {
        return $this->hasMany(Settlement::class);
    }

    public function appendices()
    {
        return $this->hasMany(Appendix::class);
    }
}
