Last active
January 2, 2018 12:42
-
-
Save hugofabricio/31e734ee8c5bc8711e9cf63c99863d17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Controller | |
public function edit($id) | |
{ | |
//passar o model com id | |
$usu = User::find($id); | |
$perf = Perfil::all(); | |
$oper = Operacao::all(); | |
// Get building categories | |
$user_opps = []; | |
foreach($usu->operacaos as $opp): | |
$user_opps[$opp->Operacao_ID] = true; | |
endforeach; | |
return view('usuario.edit', compact('usu', 'perf', 'oper', 'user_opps')); | |
} | |
// View | |
<div class="input-group"> | |
@foreach($oper as $opp) | |
@if($opp->Operacao_Status == 1 && $usu->perfil_id == 2) | |
<input type="checkbox" | |
name="ids_operacoes[{{ $opp->Operacao_ID }}]" | |
value="{{ $opp->Operacao_ID }}" | |
{{ isset($user_opps[$opp->Operacao_ID]) ? 'checked' : '' }} | |
/> | |
{{ $opp->Operacao_Status }} {{ $opp->Operacao_Descricao }} | |
@endif | |
@endforeach | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment