<?php

namespace App\Models\Office;

use App\Models\User;
use App\Traits\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Notification extends Model
{
    use BelongsToStore;

    const UPDATED_AT = null;

    protected $table = 'notifications';

    protected $fillable = [
        'store_id', 'user_id', 'title', 'content', 'type',
        'related_type', 'related_id', 'is_read', 'read_at',
    ];

    protected function casts(): array
    {
        return [
            'type' => 'integer',
            'is_read' => 'boolean',
            'read_at' => 'datetime',
        ];
    }

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