Skip to content

Instantly share code, notes, and snippets.

@avew
Created December 18, 2014 09:45
Show Gist options
  • Select an option

  • Save avew/7f3a373d9bce505d56ed to your computer and use it in GitHub Desktop.

Select an option

Save avew/7f3a373d9bce505d56ed to your computer and use it in GitHub Desktop.
Create elements for dropdown in model
#Add in your model
class Example extends Eloquent{
public function scopeDropdown()
{
return $this->lists('title','id');
}
}
#Add in your controller
#example in method show
class ExampleController extends BaseController{
public function show()
{
$exampledropdown = Example::dropdown();
return View::make('example', compact('exampledropdown'));
}
}
#Add in yor view (view/example.blade.php)
@extends('your-layout')
@section('your-section')
{{ Form::open(array('url' => 'example','method' => 'post')) }}
{{ Form::label('example', 'Example'); }}
{{ Form::select('example', $exampledropdown) }}
{{ Form::close() }}
@stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment