<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class IftaReply extends Model
{
    protected $fillable = [
        'ifta_question_id',
        'user_id',
        'body',
        'is_official',
        'is_approved',
        'approved_at',
        'approved_by',
    ];

    protected function casts(): array
    {
        return [
            'is_official' => 'boolean',
            'is_approved' => 'boolean',
            'approved_at' => 'datetime',
        ];
    }

    public function question()
    {
        return $this->belongsTo(IftaQuestion::class, 'ifta_question_id');
    }

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

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