Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lobz committed Aug 2, 2024
1 parent 9973a76 commit b77424c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
15 changes: 14 additions & 1 deletion app/Http/Controllers/TurmaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
29 changes: 17 additions & 12 deletions resources/views/turma/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,24 @@
@include('user.table',['users' => $turma->users, 'editButton' => true, 'removeButton' => true])
</div>

<a class="collapse-button" data-toggle="collapse" href="#collapsePrazosFuturos" role="button" aria-expanded="true" aria-controls="collapsePrazosFuturos">
<h2>Prazos Futuros</h2>
</a>
<div class="collapse" id="collapsePrazosFuturos">
@include('prazo.table',['prazos' => $turma->prazos->where('futuro')])
</div>
@if($prazosFuturos ?? '')
<a class="collapse-button" data-toggle="collapse" href="#collapsePrazosFuturos" role="button" aria-expanded="true" aria-controls="collapsePrazosFuturos">
<h2>Prazos Futuros</h2>
</a>
<div class="collapse" id="collapsePrazosFuturos">
@include('prazo.table',['prazos' => $prazosFuturos])
</div>

<a class="collapse-button" data-toggle="collapse" href="#collapsePrazosPassados" role="button" aria-expanded="true" aria-controls="collapsePrazosPassados">
<h2>Prazos Passados</h2>
</a>
<div class="collapse" id="collapsePrazosPassados">
@include('prazo.table',['prazos' => $turma->prazos->where('passado')])
</div>
@endif

@if($prazosPassados ?? '')
<a class="collapse-button" data-toggle="collapse" href="#collapsePrazosPassados" role="button" aria-expanded="true" aria-controls="collapsePrazosPassados">
<h2>Prazos Passados</h2>
</a>
<div class="collapse" id="collapsePrazosPassados">
@include('prazo.table',['prazos' => $prazosPassados])
</div>
@endif


@can ('delete', $turma)
Expand Down

0 comments on commit b77424c

Please sign in to comment.