ctrlpanel/app/Models/Configuration.php

35 lines
652 B
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?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;
}
}