33 lines
939 B
PHP
33 lines
939 B
PHP
<?php
|
|
|
|
namespace Database\Seeders\Development;
|
|
|
|
use App\Models\FaqQuestion;
|
|
use App\Models\FaqTheme;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
class QuestionSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run(): void
|
|
{
|
|
Schema::disableForeignKeyConstraints();
|
|
DB::table('faq_themes')->truncate();
|
|
DB::table('faq_questions')->truncate();
|
|
Schema::enableForeignKeyConstraints();
|
|
|
|
FaqTheme::factory(4)->create()->each(function (FaqTheme $question_theme) {
|
|
FaqQuestion::factory(fake()->numberBetween(2, 6))->make()
|
|
->each(function (FaqQuestion $faq_question) use ($question_theme) {
|
|
$faq_question->theme()->associate($question_theme);
|
|
$faq_question->save();
|
|
});
|
|
});
|
|
}
|
|
}
|