<?php

namespace App\Models\PensionCase;

use App\Models\User\User;
use Database\Factories\PensionCase\PensionCaseCommentFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PensionCaseComment extends Model {
    use HasFactory;

    protected static function newFactory(): PensionCaseCommentFactory {
        return PensionCaseCommentFactory::new();
    }

    protected $table = 'pension_case_comments';

    protected $fillable = [
        'pension_case_id',
        'comment_created_by',
        'comment_created_at',
        'comment_text',
    ];

    protected $casts = [
        'comment_created_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

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

    public function author(): BelongsTo {
        return $this->belongsTo(User::class, 'comment_created_by');
    }
}
