<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use App\Traits\GlobalModelEvents;

class Blog extends Model
{
    use HasFactory, GlobalModelEvents;

    protected $fillable = [
        'title', 'slug', 'featured_image', 'content', 'author_name', 'author_title', 'views', 'status',
    ];
    
    public function setTitleAttribute($value)
    {
        $this->attributes['title'] = $value;
        $this->attributes['slug'] = Str::slug($value);
    }
}
