-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSetting.php
38 lines (31 loc) · 803 Bytes
/
Setting.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
protected $table = "settings";
protected $fillable = [
"key", "value",
];
public static function paginacao()
{
return self::val("paginacao", 15);
}
public static function val($key, $default = null)
{
try {
$setting = Setting::where("key", $key)->first();
if (!$setting) {
Setting::create(["key" => $key, "value" => $default]);
return $default;
}
return $setting->value;
} catch (\Exception $excecao) {
return $default;
}
}
public static function dateTime()
{
return self::val("formato-data-hora", "d/m/Y H:i:s");
}
}