<?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 Blog extends Model
{
    protected $fillable = [
        'category_id',
        'title',
        'slug',
        'image',
        'content',
        'seo_title',
        'seo_description',
        'seo_keywords',
        'count_view',
        'status'
    ];


    public function category(): BelongsTo
    {
        return $this->belongsTo(blogCategories::class, 'category_id');
    }

    public function getStatusLabelAttribute(): string
    {
        return match($this->attributes['status']) {
            'draft' => 'پیش نویس',
            'published' => 'منتشرشده',
            default => 'پیش نویس',
        };
    }
}
