This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/app/Models/Setting.php

65 lines
1.5 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 = [
'',
];
/*
* Public setting keys
*/
static public $publicKeys = [
'registration_possible',
'invites',
'url',
'name',
'recaptcha_v2_register',
'recaptcha_v2_login',
'recaptcha_v2_key',
'name_big',
'name_small',
'name_slogen'
];
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) {
//Hack for old gui
return Setting::query()->where("name", "=", $name)->firstOrFail()->value;
}
static public function getPublicSettings() {
return Setting::query()->whereIn("name", self::$publicKeys)->get();
}
}