Skip to content

feat: add school seed data #1043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/Console/Commands/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace App\Console\Commands;

use App\Models\Form;
use App\Models\Language;
use App\Models\Page;
use App\Models\Person;
use App\Models\Setting;
use App\Models\User;
use App\Services\SupportsTrait;
Expand Down Expand Up @@ -45,6 +47,8 @@ public function handle()
$this->seedLanguages();
$this->seedSettings();
$this->seedPages();
$this->seedPeople();
$this->seedForms();
$this->seedAdministrator();

self::clearResponseCache();
Expand Down Expand Up @@ -110,6 +114,32 @@ protected function seedPages(): void
});
}

protected function seedPeople(): void
{
if (Person::count()) {
return;
}

$this->info('Creating default people...');

$this->loadData('people')->each(function (array $attributes) {
$person = $this->saveModel(Person::class, $attributes);
});
}

protected function seedForms(): void
{
if (Form::count()) {
return;
}

$this->info('Creating default forms...');

$this->loadData('forms')->each(function (array $attributes) {
$form = $this->saveModel(Form::class, $attributes);
});
}

protected function seedAdministrator(): void
{
if (User::count()) {
Expand Down
68 changes: 68 additions & 0 deletions database/seeders/data/school/forms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
{
"title": {
"ro": "Formular de contact"
},
"slug": {
"ro": "formular-de-contact"
},
"description": {
"ro": "<p>Dac\u0103 ai vreo \u00eentrebare sau te confrun\u021bi cu vreo problem\u0103, completeaz\u0103 acest formular. <\/p>"
},
"store_submissions": true,
"send_submissions": false,
"recipients": null,
"blocks": [
{
"type": "text",
"content": {
"fullwidth": true,
"label": {
"ro": "Nume"
},
"help": [],
"required": true,
"min_length": 1,
"max_length": 200
}
},
{
"type": "email",
"content": {
"fullwidth": false,
"label": {
"ro": "Adresa de e-mail"
},
"help": [],
"required": true
}
},
{
"type": "text",
"content": {
"fullwidth": false,
"label": {
"ro": "Num\u0103rul de telefon"
},
"help": [],
"required": false,
"min_length": 1,
"max_length": 20
}
},
{
"type": "textarea",
"content": {
"fullwidth": true,
"label": {
"ro": "Mesaj"
},
"help": [],
"required": true,
"min_length": 1,
"max_length": 0
}
}
]
}
]
Loading