<?php

namespace App\Models\Tenant;

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

class ClientNotificationLog extends Model
{
    use BelongsToTenant;

    public $timestamps = false;
    protected $table = 'client_notifications_log';

    public const CHANNELS = [
        'sms' => 'SMS',
        'whatsapp' => 'WhatsApp',
        'telegram' => 'Telegram',
        'email' => 'Email',
        'push' => 'Web Push',
    ];

    public const STATUSES = [
        'sent' => 'Trimis',
        'delivered' => 'Livrat',
        'failed' => 'Eșuat',
        'read' => 'Citit',
    ];

    protected $fillable = [
        'company_id', 'work_order_id', 'client_id',
        'channel', 'template_key', 'message_text', 'status', 'error_detail',
        'sent_at', 'delivered_at',
    ];

    protected $casts = [
        'sent_at' => 'datetime',
        'delivered_at' => 'datetime',
    ];

    public function workOrder(): BelongsTo { return $this->belongsTo(WorkOrder::class); }
    public function client(): BelongsTo { return $this->belongsTo(Client::class); }
}
