You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Miscellaneous\WebsiteSetting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
abstract class BaseSettingsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Get the settings array to be seeded.
|
||||
* Override this in child classes.
|
||||
*/
|
||||
abstract protected function getSettings(): array;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
foreach ($this->getSettings() as $setting) {
|
||||
WebsiteSetting::firstOrCreate(
|
||||
['key' => $setting['key']],
|
||||
[
|
||||
'key' => $setting['key'],
|
||||
'value' => $setting['value'],
|
||||
'comment' => $setting['comment'] ?? null,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a setting array with common structure.
|
||||
*/
|
||||
protected function setting(string $key, string $value, string $comment = ''): array
|
||||
{
|
||||
return [
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'comment' => $comment,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user