Skip to content

Commit

Permalink
add topico seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lobz committed Jul 1, 2024
1 parent 7a7e844 commit 03d34ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
10 changes: 9 additions & 1 deletion database/factories/TopicoFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace Database\Factories;
use App\Models\Topico;

use Illuminate\Database\Eloquent\Factories\Factory;

Expand All @@ -9,6 +10,12 @@
*/
class TopicoFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Topico::class;
/**
* Define the model's default state.
*
Expand All @@ -17,7 +24,8 @@ class TopicoFactory extends Factory
public function definition(): array
{
return [
//
'name' => $this->faker->sentence(3),
'order' => $this->faker->randomNumber(1),
];
}
}
17 changes: 14 additions & 3 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 App\Models\Topico;
use Monolog\Handler\SamplingHandler;

class DatabaseSeeder extends Seeder
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions resources/views/topico/table.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@foreach ($topicos as $value)

<a class="collapse-button collapsed" data-toggle="collapse"
href="#topico{{$value->order}}"
href="#topico{{$value->id}}"
role="button" aria-expanded="false"
aria-controls="topico{{$value->order}}">
aria-controls="topico{{$value->id}}">
<h2>
{{$value->name}}
<i class="fa fa-chevron-right rotate"></i>
Expand All @@ -14,7 +14,7 @@
@endcan
</h2>
</a>
<div class="collapse" id="topico{{$value->order}}">
<div class="collapse" id="topico{{$value->id}}">
@include('exercicio.table', ['editButton' => true, 'exercicios' => $value->exercicios])
</div>

Expand Down

0 comments on commit 03d34ca

Please sign in to comment.