Search
 
SCRIPT & CODE EXAMPLE
 

PHP

loop variable in laravel

Property			Description
$loop->index		The index of the current loop iteration (starts at 0).
$loop->iteration	The current loop iteration (starts at 1).
$loop->remaining	The iterations remaining in the loop.
$loop->count		The total number of items in the array being iterated.
$loop->first		Whether this is the first iteration through the loop.
$loop->last			Whether this is the last iteration through the loop.
$loop->even			Whether this is an even iteration through the loop.
$loop->odd			Whether this is an odd iteration through the loop.
$loop->depth		The nesting level of the current loop.
$loop->parent		When in a nested loop, the parent's loop variable.
Comment

laravel loop variable

@foreach($listdata as $data)
	// normal iteration
		{{ $data->iteration() }}

	// if you using "paginate()" in your query, better use this iteration per-page below:
		// for example:
			// page 1 iteration = 1,2,3,4,5 ascending, 5,4,3,2,1 descending
			// and page 2 iteration will be = 6,7,8,9,10 ascending, 10,9,8,7,6 descending

        // iteration ascending (1,2,3,...)
            {{ $data->firstItem() + $loop->index }}

        // iteration descending (...,3,2,1)
            {{ ($data->total()-$loop->index) - (($data->currentpage()-1) * $data->perpage()) }}
@endforeach
Comment

PREVIOUS NEXT
Code Example
Php :: php capitalize first letter 
Php :: woocommerce get post meta 
Php :: php number format 
Php :: find curren monday in laravel carbon 
Php :: laravel query select from table where id != to another table id 
Php :: php show active page 
Php :: wordpress custom post type disable add new 
Php :: php get tempfile 
Php :: php run command line 
Php :: add log in laravel 
Php :: foreach stdclass object php 
Php :: hmtl remove tag php 
Php :: symfony datetime now 
Php :: laravel query string 
Php :: php empty array 
Php :: laravel menu active class 
Php :: how to check using what guard in laravel 8 
Php :: get am pm 12 hour timee laravel 
Php :: laravel log could not be opened fix 
Php :: php get country from cloudflare 
Php :: get parameter php 
Php :: php get keys and values from array 
Php :: debian php switch version 
Php :: bigtext migration laravel 
Php :: laravel delete 
Php :: enque scripts from plugin 
Php :: laravel 8: bootstrap 
Php :: php regex string contains coringa 
Php :: symfony migrate fresh 
Php :: echo ternary php 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =