<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class CustomerInvoice extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'store_id', 'local_id',
        'customer_id', 'customer_name',
        'invoice_type', 'invoice_number',
        'reference_id', 'reference_type',
        'total_amount', 'status', 'invoice_date', 'notes',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'total_amount' => 'float',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
        'invoice_date' => 'datetime',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
