0

I'm using laratrust with roles and permission, now in my Roles edit-page, I loop all my permissions and I'm trying to make the checkbox auto check based on the permissions that are already given to a certain role.

Now I'm getting an error:

(Parse error: syntax error, unexpected ':', expecting)

Could anyone fix my code?

Edit.Blade

<div class="from-group">
    @foreach ($permissions as $permission)
        <div class="checkbox">
            <label>
                <input 
                    type="checkbox"  
                    name="permissions[]" 
                    value="{{$permission->id}}" 
                    @if($role->permissions) 
                        @if(in_array($permission->id, $role->permissions->pluck('id')))
                            checked 
                        @endif 
                    @endif
                 >
                 <span>
                     {{$permission->display_name}} 
                     <em>({{$permission->description}})</em>
                </span>
            </label>
        </div>
    @endforeach
</div>
Rahul Reghunath
  • 1,210
  • 13
  • 23
Copain
  • 163
  • 3
  • 18

1 Answers1

0

change your condition to

@if(in_array($permission->id, $role->permissions->pluck('id')->toArray() ))

you miss last ) bracket And The in_array() function searches an array for a specific value so second value must be an array

Rahul Reghunath
  • 1,210
  • 13
  • 23