45 lines
1 KiB
PHP
45 lines
1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Auth\Authenticatable;
|
||
|
use Laravel\Lumen\Auth\Authorizable;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||
|
|
||
|
class Setting extends Model
|
||
|
{
|
||
|
/**
|
||
|
* The attributes that are mass assignable.
|
||
|
*
|
||
|
* @var array
|
||
|
*/
|
||
|
protected $fillable = [
|
||
|
'name', 'description', 'typ', 'value'
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* The attributes excluded from the model's JSON form.
|
||
|
*
|
||
|
* @var array
|
||
|
*/
|
||
|
protected $hidden = [
|
||
|
'',
|
||
|
];
|
||
|
|
||
|
|
||
|
static public function getSettingsAsArray() {
|
||
|
$settings = Setting::query()->get();
|
||
|
$settingsArray = [];
|
||
|
foreach($settings as $s) {
|
||
|
$settingsArray[$s->name] = $s->value;
|
||
|
}
|
||
|
return $settingsArray;
|
||
|
}
|
||
|
|
||
|
static public function getSettingValue($name) {
|
||
|
return Setting::query()->where("name", "=", $name)->firstOrFail()->value;
|
||
|
}
|
||
|
}
|