phpvms/app/Models/Setting.php

39 lines
737 B
PHP
Raw Normal View History

<?php
namespace App\Models;
class Setting extends BaseModel
{
public $table = 'settings';
public $incrementing = false;
public $fillable = [
'name',
'key',
'value',
'group',
'type',
'options',
'description',
];
2018-01-01 01:19:18 +08:00
public static function formatKey($key)
{
return str_replace('.', '_', strtolower($key));
}
protected static function boot()
{
parent::boot();
/**
* Make sure any dots are replaced with underscores
*/
static::creating(function (Setting $model) {
if (!empty($model->id)) {
2018-01-01 01:19:18 +08:00
$model->id = Setting::formatKey($model->id);
}
});
}
}