Publication initiale de RelaisSMS : documentation et sources nettoyees

This commit is contained in:
2026-10-21 09:29:39 +02:00
commit ac186b03b1
158 changed files with 24818 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace Database\Seeders;
use App\Models\AppSetting;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use RuntimeException;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$email = (string) env('RELAIS_SMS_ADMIN_EMAIL', 'admin@relais-sms.test');
$password = (string) env('RELAIS_SMS_ADMIN_PASSWORD', 'relais-sms');
if (! app()->environment(['local', 'testing'])
&& ! User::query()->where('email', $email)->exists()
&& (trim($password) === '' || $password === 'relais-sms')) {
throw new RuntimeException('Definissez un mot de passe administrateur personnel dans RELAIS_SMS_ADMIN_PASSWORD avant de creer le compte hors developpement.');
}
$settings = collect(config('relais_sms.default_settings'))
->map(fn (mixed $value, string $key): array => [
'key' => $key,
'value' => is_bool($value) ? (string) (int) $value : (string) $value,
'type' => match (true) {
is_bool($value) => 'boolean',
is_int($value) => 'integer',
default => 'string',
},
])
->values()
->all();
AppSetting::upsert($settings, ['key'], ['value', 'type']);
User::query()->firstOrCreate([
'email' => $email,
], [
'name' => env('RELAIS_SMS_ADMIN_NAME', 'Administrateur RelaisSMS'),
'password' => Hash::make($password),
]);
}
}