Initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
];
|
||||
|
||||
public static function getValue(string $key, mixed $default = null): mixed
|
||||
{
|
||||
return static::query()->where('key', $key)->value('value') ?? $default;
|
||||
}
|
||||
|
||||
public static function setValue(string $key, mixed $value): void
|
||||
{
|
||||
static::query()->updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
|
||||
public static function brandingDefaults(): array
|
||||
{
|
||||
return [
|
||||
'app_name' => 'Database Kesiswaan',
|
||||
'app_short_name' => 'DK',
|
||||
'app_logo' => null,
|
||||
'app_favicon' => null,
|
||||
'public_portal_logo' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public static function branding(): array
|
||||
{
|
||||
$defaults = static::brandingDefaults();
|
||||
|
||||
foreach (array_keys($defaults) as $key) {
|
||||
$defaults[$key] = static::getValue($key, $defaults[$key]);
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user