$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\Database\Eloquent\Collection($category);
{{ $category->paginate(60) }}
@forelse($category as $categoryes)
@if($categoryes->pid == null)
{{$categoryes->name_group}}
@endif
@empty
<p></p>
@endforelse
<div align="center"><?php echo $category->render(); ?></div>
// КОД в 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() }}
//КОД в 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
);
$category = Auto::all()->map(function($item){
if( ((Auto::where('pid', '=',$item->c_id_group)->count()))>0){
$item->chil=1;
}
return $item;
});
$currentPage = \Illuminate\Pagination\Paginator::resolveCurrentPage();
$prePage = 60;
$category = new \Illuminate\Pagination\LengthAwarePaginator(
$category->forPage($currentPage, $prePage), $category->count(), $prePage, $currentPage
);
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()->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() }}