// КОД в php
$category = Auto::all()->map(function($item){
if( ((Auto::where('pid', '=',$item->c_id_group)->count()))>0){
$item->chil=1;
}else{
$item->chil=0;
}
return $item;
});
$category = new \Illuminate\Pagination\LengthAwarePaginator(
$category, $category->count(), 60, \Illuminate\Pagination\Paginator::resolveCurrentPage()
);
//КОД в шаблоне blade
@forelse($category as $categoryes)
@if($categoryes->pid == null)
{{$categoryes->name_group}}
@endif
@empty
<p></p>
@endforelse
{{ $category->render() }}