From 04585c90250e346df3f0c25538be1e68f3282f1c Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Fri, 2 Aug 2024 17:02:52 -0300 Subject: [PATCH] add curso to turma form --- app/Http/Controllers/TurmaController.php | 8 ++++++-- resources/views/turma/create.blade.php | 14 ++++++++++++++ resources/views/turma/edit.blade.php | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TurmaController.php b/app/Http/Controllers/TurmaController.php index e15f772..86fef88 100644 --- a/app/Http/Controllers/TurmaController.php +++ b/app/Http/Controllers/TurmaController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use Illuminate\View\View; use App\Models\Turma; +use App\Models\Curso; use App\Models\User; use App\Models\Exercicio; use App\Models\Prazo; @@ -61,7 +62,9 @@ public function index() public function create() { $this->authorize('create', Turma::class); - return View('turma.create')->with('turmas', Turma::all()); + return View('turma.create') + ->with('turmas', Turma::all()) + ->with('cursos', Curso::all()); } /** @@ -145,7 +148,8 @@ public function edit(Turma $turma) $this->authorize('edit', $turma); $prazos = $turma->prazosOrdered()->get()->groupBy('futuro'); - $v = View('turma.edit')->with('turma',$turma); + $v = View('turma.edit')->with('turma',$turma) + ->with('cursos', Curso::all()); if ($prazos->isNotEmpty()) { if ($prazos->keys()->contains(0)) { diff --git a/resources/views/turma/create.blade.php b/resources/views/turma/create.blade.php index d06b045..7610674 100644 --- a/resources/views/turma/create.blade.php +++ b/resources/views/turma/create.blade.php @@ -20,6 +20,20 @@ class="form-control @error('name') is-invalid @enderror" @enderror +
+ + @php($old_curso = old('curso_id', null)) + + @error('curso_id') +
{{ $message }}
+ @enderror +
+