//КОД в php
$category = Auto::all()->filter(function($item){
if ($item->pid == null) {
if( Auto::where('pid', '=',$item->c_id_group)->count() > 0 ){
$item->chil=1;
}else{
$item->chil=0;
}
return $item;
}
});
$currentPage = \Illuminate\Pagination\Paginator::resolveCurrentPage();
$prePage = 60;
$category = new \Illuminate\Pagination\LengthAwarePaginator(
$category->forPage($currentPage, $prePage), $category->count(), $prePage, $currentPage
);
//КОД в шаблоне blade
@forelse($category as $categoryes)
{{ $categoryes->name_group }}
@empty
<p></p>
@endforelse
{{ $category->render() }}
LengthAwarePaginator {#494 ▼
#total: 70
#lastPage: 7
#items: Collection {#226 ▼
#items: array:10 [▼
0 => StreetType {#495 ▶}
1 => StreetType {#496 ▶}
2 => StreetType {#497 ▶}
3 => StreetType {#498 ▶}
4 => StreetType {#499 ▶}
5 => StreetType {#500 ▶}
6 => StreetType {#501 ▶}
7 => StreetType {#502 ▶}
8 => StreetType {#503 ▶}
9 => StreetType {#504 ▶}
]
}
#perPage: 10
#currentPage: 1
#path: "/"
#query: []
#fragment: null
#pageName: "page"
}
//КОД в 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;
});
$currentPage = \Illuminate\Pagination\Paginator::resolveCurrentPage();
$prePage = 60;
$category = new \Illuminate\Pagination\LengthAwarePaginator(
$category->forPage($currentPage, $prePage), $category->count(), $prePage, $currentPage
);
var module = 'Test';
require.ensure([module], require => {
require(module);
});
Спасибо!