31 lines
639 B
PHP
31 lines
639 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Setting extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'key',
|
|
'value',
|
|
'type',
|
|
];
|
|
|
|
/**
|
|
* Get the strongly typed value based on type.
|
|
*/
|
|
public function getTypedValue()
|
|
{
|
|
return match ($this->type) {
|
|
'boolean' => filter_var($this->value, FILTER_VALIDATE_BOOLEAN),
|
|
'integer' => (int) $this->value,
|
|
'json' => json_decode($this->value, true),
|
|
default => $this->value,
|
|
};
|
|
}
|
|
}
|