수색…
소개
Laravel 5.2에서 5.3까지의 새로운 기능, 개선 사항 및 변경 사항
$ loop 변수
Blade에서 루프를 처리하는 데 제한이있는 것으로 알려져 있지만 5.3 절에는 $loop
이라는 변수가 있습니다.
@foreach($variables as $variable)
// Within here the `$loop` variable becomes available
// Current index, 0 based
$loop->index;
// Current iteration, 1 based
$loop->iteration;
// How many iterations are left for the loop to be complete
$loop->remaining;
// Get the amount of items in the loop
$loop->count;
// Check to see if it's the first iteration ...
$loop->first;
// ... Or last iteration
$loop->last;
//Depth of the loop, ie if a loop within a loop the depth would be 2, 1 based counting.
$loop->depth;
// Get's the parent `$loop` if the loop is nested, else null
$loop->parent;
@endforeach
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow