<?php
/*
    * Created by VahabDev in Aparat Live
    * Website: https://pourfi.ir
    * Aparat Live: https://www.aparat.com/vahabdev/live
    * Aparat Channel: https://www.aparat.com/vahabdev
    * Rubika Channel: https://rubika.ir/vahabdev
    * Donate: https://reymit.ir/vahabdev
    * Telegram: https://t.me/vahabdev
*/


namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TicketReplay extends Model
{

    protected $fillable = [
        'ticket_id',
        'message',
        'date',
        'is_admin',
    ];

    protected $casts = [
        'date' => 'datetime',
        'is_admin' => 'boolean',
    ];


    public function ticket() : BelongsTo{
        return $this->belongsTo(Ticket::class, 'ticket_id', 'id');
    }

    public function getSenderTypeAttribute(): string
    {
        return $this->is_admin ? 'مدیریت' : 'کاربر';
    }

}
