I am new in Laravel development. I am working on roles and permissions in Laravel using Spatie, want to display One title name of permission list e.g I have list of property permissions then want to display Property title name on the top of the permission list, Other I have list of agency permissions then want to display Agency title name on the top of the permission list.
I have table of permissions where I add column of role_category_id which is related to other table of role_categories
Table of role_categories
My controller code is where I use join of two tables
$permission = RoleCatgory::Leftjoin("permissions","role_categories.id","=","permissions.role_category_id")
->get();
My view code
@foreach($permission as $value)
<h3>{{ $value->category_name }}</h3>
@if(in_array($value['id'],$rolePermissions))
@php
$checked="checked";
@endphp
@else
@php
$checked="";
@endphp
@endif
<div class="col-md-4 mb-2">
<input type="checkbox" class="form-check-input" id="exampleCheck" name="permission[]" @php echo $checked; @endphp value="{{ $value->id }}">
label class="form-check-label" for="exampleCheck">{{ $value->name }}</label>
</div>
@endforeach
Result is: Property title name is displayed on each permissions name but want to display only one time on property permission list