<?php

namespace Modules\Cheque\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Modules\Factor\Entities\Factor;

class Cheque extends Model
{
    protected $guarded = ['id'];


    protected static function boot()
    {
        parent::boot();

        static::creating(function ($model) {
            if (empty($model->uuid)) {
                $model->uuid = (string)Str::uuid();  // Generate UUID
            }
        });
    }

    public function exporterable()
    {
        return $this->morphTo();
    }

    public function receiverable()
    {
        return $this->morphTo();
    }

    public function factor()
    {
        return $this->belongsTo(Factor::class);
    }

    public function getImageAttribute($value)
    {
        return Storage::url($value);
    }


}
