Publication initiale de RelaisSMS : documentation et sources nettoyees
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable(['key', 'value', 'type'])]
|
||||
class AppSetting extends Model
|
||||
{
|
||||
public static function string(string $key, string $default = ''): string
|
||||
{
|
||||
$setting = self::query()->where('key', $key)->first();
|
||||
|
||||
if ($setting === null) {
|
||||
$configured = config('relais_sms.default_settings.'.$key);
|
||||
|
||||
return is_string($configured) ? $configured : $default;
|
||||
}
|
||||
|
||||
return (string) $setting->value;
|
||||
}
|
||||
|
||||
public static function putString(string $key, string $value): void
|
||||
{
|
||||
self::query()->updateOrCreate(
|
||||
['key' => $key],
|
||||
[
|
||||
'value' => $value,
|
||||
'type' => 'string',
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user