Sunday 30 April 2017

Laravel 5.4 dropdown default from database

Laravel we have more and more options Like drop-down selection from database records.

Take a simple example permissions and roles. I have to add a role with some permissions.

So I have to call permissions from the database.

RoleController:
$permissions = Permission::where('active_flag', 1)->orderBy('name')->pluck('name', 'id');
return view('roles.create',compact('permissions'));

 roles.create:


  <div class="form-group"> 
 {!! Form::label('permissions', 'Permissions:') !!} 
 {!! Form::select('permissions',$permissions, null,['id'=>'multiple-checkboxes','multiple'=>'multiple'] ) !!}
 </div>


Here I am using multiple dropdown.
Simply we can add roles with permissions.



No comments:

Post a Comment

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in Laravel

  WampServer: Download this file:  http://curl.haxx.se/ca/cacert.pem Place this file in the  C:\wamp64\bin\php\php7.1.9  folder Open  php.in...

Popular Articles