Skip to content

Commit

Permalink
organize seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lobz committed May 1, 2024
1 parent 19e88fd commit 65fb62c
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Models\Nota;
use App\Models\Prazo;
use App\Models\Teste;
use Monolog\Handler\SamplingHandler;

class DatabaseSeeder extends Seeder
{
Expand All @@ -20,46 +21,42 @@ class DatabaseSeeder extends Seeder
public function run()
{
$ind_user = User::factory()->create();
$alunos = User::factory()->count(3)->create();
$turma = Turma::factory()
->hasAttached($alunos)
->create();
$turma2 = Turma::factory()
$alunos = User::factory()->count(30)->create();

$turma_vazia = Turma::factory()->create();
$turmas = Turma::factory()->count(10)
->hasAttached($alunos)
->create();

$turma_vazia = Turma::factory()->create();
$exercicios = Exercicio::factory()->count(30)
->has(Teste::factory()->count(3))
->create();

$exercicios = Exercicio::factory()->count(5)
->has(Teste::factory()->count(3))
->create();

foreach ($exercicios as $exercicio) {
Nota::factory()->count(2)
->for($ind_user)
->for($exercicio)
->create();

Prazo::factory()
->for($turma)
->for($exercicios[1])
->create();
Prazo::factory()
->for($turma_vazia)
->for($exercicios[2])
->create();
Prazo::factory()
->for($turma_vazia)
->for($exercicio)
->create();

Nota::factory()->count(2)
->for($ind_user)
->for($exercicios[1])
->create();
Nota::factory()->count(2)
->for($ind_user)
->for($exercicios[2])
->create();
Nota::factory()->count(2)
->for($alunos[1])
->for($exercicios[1])
->create();
Nota::factory()->count(2)
->for($alunos[2])
->for($exercicios[2])
->create();
foreach ($turmas as $turma) {
Prazo::factory()
->for($turma)
->for($exercicio)
->create();
}

foreach ($alunos as $aluno) {
Nota::factory()->count(5)
->for($aluno)
->for($exercicio)
->create();
}
}
}
}

0 comments on commit 65fb62c

Please sign in to comment.