Skip to content

Instantly share code, notes, and snippets.

@timersys
Created January 9, 2015 12:25
Show Gist options
  • Select an option

  • Save timersys/948088de7187dcf8c31a to your computer and use it in GitHub Desktop.

Select an option

Save timersys/948088de7187dcf8c31a to your computer and use it in GitHub Desktop.
Laravel pass model to create dropdown in views
/**
* IF you have a States model and you want to create a simple dropdown in your views you can pass the array very easily doing:
**/
public function create()
{
// first parameter is option label and second the option value
$states = State::lists('state', 'id');
return View::make('anuncios.create', compact('states'));
}
/**
* Then in your view simple
*/
{{ Form::select('state', $states , ['class' => 'form-control choosen-select']) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment