diff --git a/app/Http/Controllers/TurmaController.php b/app/Http/Controllers/TurmaController.php index cd88d7d..e15f772 100644 --- a/app/Http/Controllers/TurmaController.php +++ b/app/Http/Controllers/TurmaController.php @@ -143,7 +143,20 @@ public function show(Turma $turma) public function edit(Turma $turma) { $this->authorize('edit', $turma); - return View('turma.edit')->with('turma',$turma); + + $prazos = $turma->prazosOrdered()->get()->groupBy('futuro'); + $v = View('turma.edit')->with('turma',$turma); + + if ($prazos->isNotEmpty()) { + if ($prazos->keys()->contains(0)) { + $v = $v->with('prazosPassados',$prazos[0]); + + } + if ($prazos->keys()->contains(1)) { + $v = $v->with('prazosFuturos',$prazos[1]); + } + } + return $v; } /** diff --git a/resources/views/turma/edit.blade.php b/resources/views/turma/edit.blade.php index f909eaf..6ca5f19 100644 --- a/resources/views/turma/edit.blade.php +++ b/resources/views/turma/edit.blade.php @@ -52,19 +52,24 @@ @include('user.table',['users' => $turma->users, 'editButton' => true, 'removeButton' => true]) - -

Prazos Futuros

-
-
- @include('prazo.table',['prazos' => $turma->prazos->where('futuro')]) -
+ @if($prazosFuturos ?? '') + +

Prazos Futuros

+
+
+ @include('prazo.table',['prazos' => $prazosFuturos]) +
- -

Prazos Passados

-
-
- @include('prazo.table',['prazos' => $turma->prazos->where('passado')]) -
+ @endif + + @if($prazosPassados ?? '') + +

Prazos Passados

+
+
+ @include('prazo.table',['prazos' => $prazosPassados]) +
+ @endif @can ('delete', $turma)