ctrlpanel/app/Models/Configuration.php
2021-06-05 11:26:32 +02:00

35 lines
652 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Configuration extends Model
{
use HasFactory;
public $primaryKey = 'key';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'key',
'value',
'type',
];
/**
* @param string $key
* @param $default
* @return mixed
*/
public static function getValueByKey(string $key , $default = null)
{
$configuration = self::find($key);
return $configuration ? $configuration->value : $default;
}
}