86 lines
1.6 KiB
PHP
86 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\Page;
|
|
use App\Traits\CastsEnumsHasTranslations;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SeoDatum extends Model
|
|
{
|
|
use HasFactory;
|
|
use CastsEnumsHasTranslations;
|
|
|
|
/**
|
|
* Map attribute names to enum classes.
|
|
*
|
|
* @var array
|
|
*/
|
|
public $enumCasts = [
|
|
'page' => Page::class
|
|
];
|
|
|
|
/**
|
|
* Engagment fillable fields
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'title',
|
|
'description',
|
|
'keywords'
|
|
];
|
|
|
|
/**
|
|
* Engagment translatable fields array
|
|
*
|
|
* @var array
|
|
*/
|
|
public $translatable = [
|
|
'title',
|
|
'description',
|
|
'keywords'
|
|
];
|
|
|
|
/**
|
|
* Get the route key for the model.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getRouteKeyName()
|
|
{
|
|
return 'page';
|
|
}
|
|
|
|
/**
|
|
* Get Generic attribute value
|
|
*
|
|
* @param mixed $key
|
|
* @return mixed
|
|
*/
|
|
public function getAttributeValue($key)
|
|
{
|
|
if ($this->hasEnumCast($key)) {
|
|
$value = parent::getAttributeValue($key);
|
|
return $this->castToEnum($key, $value);
|
|
}
|
|
|
|
return $this->TransGetAttributeValue($key);
|
|
}
|
|
|
|
/**
|
|
* Set a given attribute on the model.
|
|
*
|
|
* @param mixed $key
|
|
* @param mixed $value
|
|
* @return mixed
|
|
*/
|
|
public function setAttribute($key, $value)
|
|
{
|
|
if ($this->hasEnumCast($key)) {
|
|
return $this->EnumSetAttribute($key, $value);
|
|
}
|
|
return $this->TransSetAttribute($key, $value);
|
|
}
|
|
}
|