Monday, March 6, 2017

Select not show selected role: Laravel 5.4 + Senitinel

Controller:

public function useredit($id){
$user = User::FindOrFail($id);
// return $user->roles->pluck('id')->all();
$allroles = Sentinel::getRoleRepository()->pluck('name','id');
return view('admin.edit',compact('allroles','user'));

View:

{!! Form::label('RoleList','Wybierz role')!!} {!! Form::select('RoleList[]',$allroles, null,['class' => 'form-control','multiple'])!!}
@if ($errors->has('RoleList'))

@endif

EloquentUser

public function getRoleListAttribute(){
return $this->roles->pluck('id')->all();
}

Roles is listting but still selected its not working :/

enter image description here



via Marcin Maj

Advertisement