From 03d34ca51175030c5710a2dd2b8570b76fe84832 Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Mon, 1 Jul 2024 16:27:14 -0300 Subject: [PATCH] add topico seeder --- database/factories/TopicoFactory.php | 10 +++++++++- database/seeders/DatabaseSeeder.php | 17 ++++++++++++++--- resources/views/topico/table.blade.php | 6 +++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/database/factories/TopicoFactory.php b/database/factories/TopicoFactory.php index 774eb35..dd45736 100644 --- a/database/factories/TopicoFactory.php +++ b/database/factories/TopicoFactory.php @@ -1,6 +1,7 @@ $this->faker->sentence(3), + 'order' => $this->faker->randomNumber(1), ]; } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index b90b124..38ec899 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -9,6 +9,7 @@ use App\Models\Nota; use App\Models\Prazo; use App\Models\Teste; +use App\Models\Topico; use Monolog\Handler\SamplingHandler; class DatabaseSeeder extends Seeder @@ -21,17 +22,27 @@ class DatabaseSeeder extends Seeder public function run() { $ind_user = User::factory()->create(); - $alunos = User::factory()->count(10)->create(); + $alunos = User::factory()->count(5)->create(); $turma_vazia = Turma::factory()->create(); $turmas = Turma::factory()->count(3) ->hasAttached($alunos) ->create(); - $exercicios = Exercicio::factory()->count(5) - ->has(Teste::factory()->count(3)) + $topicos = Topico::factory()->count(2)->create(); + + foreach ($topicos as $key => $topico) { + Exercicio::factory()->count(2) + ->has(Teste::factory()->count(2)) + ->for($topico) + ->create(); + } + + Exercicio::factory()->count(3) + ->has(Teste::factory()->count(2)) ->create(); + $exercicios = Exercicio::all(); foreach ($exercicios as $exercicio) { Nota::factory()->count(2) diff --git a/resources/views/topico/table.blade.php b/resources/views/topico/table.blade.php index 23d8016..0655215 100644 --- a/resources/views/topico/table.blade.php +++ b/resources/views/topico/table.blade.php @@ -1,9 +1,9 @@ @foreach ($topicos as $value) -
+
@include('exercicio.table', ['editButton' => true, 'exercicios' => $value->exercicios])