<?php

namespace App\Models\Lookups;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;

class CashMovementReason extends Model
{
    use BelongsToTenant;

    public const PETTY_CASH = 'petty_cash';

    public const BANK_DEPOSIT = 'bank_deposit';

    public const SUPPLIER_PAYMENT = 'supplier_payment';

    public const OWNER_WITHDRAWAL = 'owner_withdrawal';

    public const EXPENSE = 'expense';

    public const OTHER = 'other';

    protected $fillable = [
        'code', 'name', 'requires_note', 'sort_order', 'is_active',
    ];

    protected function casts(): array
    {
        return [
            'requires_note' => 'boolean',
            'is_active' => 'boolean',
            'sort_order' => 'integer',
        ];
    }

    public static function findByCode(string $code): ?self
    {
        return static::query()->where('code', $code)->first();
    }
}
