You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
891 B
30 lines
891 B
<?php
|
|
|
|
namespace App\Domains\System\Models;
|
|
|
|
use App\Domains\System\Enums\SystemSettingKey;
|
|
use App\UI\Enums\InputType;
|
|
use Exception;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
#[Fillable(['key', 'value'])]
|
|
#[WithoutTimestamps]
|
|
class SystemSettings extends Model
|
|
{
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function getTranslatedValueAttribute(): ?string
|
|
{
|
|
$key = SystemSettingKey::tryFrom($this->attributes['key']);
|
|
if ($key->inputType() == InputType::FILE && isset($this->attributes['value'])) {
|
|
return asset_static($this->attributes['value']);
|
|
} elseif ($key->inputType() == InputType::SELECT) {
|
|
return $key->options()[$this->attributes['value']];
|
|
}
|
|
|
|
return $this->attributes['value'];
|
|
}
|
|
}
|
|
|