6
I have a select that when I change its value it should reorder a list, e.g.: by id, name, etc. without Laravel I would use a function onchange
and pass the sorting pattern to a PHP page that would print out this sorted list for me...
But how do I do that with Laravel? I’ll have to generate one view? I tried but I couldn’t...
I was trying here I think I’m missing the time to generate the views..
I have a layout view that has a @yeld ('content')
, in case I would need to update only this content, however, when I do:
$this->layout->content = View::make('usuarios.index', $variaveis);
it duplicates my layout within div content
//Follow the controller
if(Request::ajax()){
$usuarios = Usuario::orderBy(Input::get('order'),'ASC')->get();
$variaveis = array('usuarios' => $usuarios);
return View::make('usuarios.index', $variaveis);;
}else{
$usuarios = Usuario::orderBy('id','ASC')->get();
$variaveis = array('usuarios' => $usuarios);
$this->layout->content = View::make('usuarios.index', $variaveis);
}
But he’s never entering Request::ajax() and I can’t figure out why
put part of your code there.
– Daniel Lemes
I edited my answer to explain how Ttu does it based on your code.
– Daniel Lemes