<?php

namespace App\Models;

use Cviebrock\EloquentSluggable\Sluggable;
use Cviebrock\EloquentSluggable\SluggableScopeHelpers;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Feature extends Model
{
    use HasFactory;

    use Sluggable;
    use SluggableScopeHelpers;

    protected $fillable = [
        'title_ar',
        'title_en',
        'desc_ar',
        'desc_en',
        'user_id',
        'photo',
    ];

    // get name translation
    public function getTitleAttribute()
    {
        return $this->attributes['title_' . app()->getLocale()];
    } // end getNameAttribute



    public function keywords()
    {
        return $this->morphMany(KeyWord::class, 'keywordable');
    }

    public function sluggable(): array
    {
        return [
            'slug' => [
                'source' => 'title_ar',
                'onUpdate' => true,
            ]
        ];
    }
}
