Created
December 18, 2014 09:45
-
-
Save avew/7f3a373d9bce505d56ed to your computer and use it in GitHub Desktop.
Create elements for dropdown in model
This file contains hidden or 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
| #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