<?php

namespace App\Models;

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

class CompanyAsset extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'company_id',
        'asset_number',
        'name',
        'description',
        'category',
        'purchase_value',
        'current_value',
        'purchase_date',
        'vendor_name',
        'location',
        'status',
        'warranty_expiry',
        'notes',
        'receipt_path',
        'created_by',
    ];

    protected $casts = [
        'purchase_value' => 'decimal:2',
        'current_value' => 'decimal:2',
        'purchase_date' => 'date',
        'warranty_expiry' => 'date',
    ];

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

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