<?php

namespace App\Models;

use App\Traits\HasActive;
use App\Traits\HasTableName;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Blog extends Model
{
    use HasActive;
    use HasFactory;
    use HasTableName;

    public function getRouteKeyName(): string
    {
        return 'slug';
    }

    public function view(): Attribute
    {
        return Attribute::make(
            get: fn () => 'blog.'.$this->slug
        );
    }
}
