Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Created November 23, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/8fc08a4f06f79871b2837821547ecfcb to your computer and use it in GitHub Desktop.
Save IgorDePaula/8fc08a4f06f79871b2837821547ecfcb to your computer and use it in GitHub Desktop.
<?php
...
class HospitalCnotroller{
public function index(Request $request){
$hospitas = Hospital::all()->pluck('nome','id');
$dados = Servidor::where('hospital',$request->hospital)->paginate();
return view('servidores',['dados'=>$dados,'hospital'=>$hospital,'hospitais'=>$hospitais]);
}
}
<form>
<select>
@foreach($ospitais as $hosp)
<option value="{{$hosp->id}}">{{$hosp->name}}</option>
@endforeach
</select>
</form>
@foreach($dados as $dado)
<tr><td>{{$dado->nome}}</td><td>{{$dado->sobrenome}}</td></tr>
@endforeach
@dados->append(['hospital'=>$hospital])->links()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment