Init commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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',
|
||||
'description'
|
||||
];
|
||||
|
||||
public static function getValue($key, $default = null)
|
||||
{
|
||||
$setting = static::where('key', $key)->first();
|
||||
return $setting ? $setting->value : $default;
|
||||
}
|
||||
|
||||
public static function setValue($key, $value, $description = null)
|
||||
{
|
||||
return static::updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value, 'description' => $description]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user