<?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 Announcement extends Model
{
    use BelongsToStore;

    protected $fillable = [
        'store_id', 'title', 'content', 'type', 'is_top',
        'publish_status', 'published_at', 'author_id',
    ];

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

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