about $loop->iteration and paginate i already doing paginate(4)
and doing
@foreach ()
$loop->iteration
@endforeach
i want column No continue if i change to next page (paginate),
the detail code
<th scope="col">No</th>
@foreach ($attend as $data)
<tr>
<th scope="row">{{ $loop->iteration }}</th>
...
my controller
$attend = Absensi::Paginate(4);
return view('attend.home',['attend'=>$attend]);
Do you mean like
<th scope="row">{{ $loop->iteration * $attend->currentPage() }}</th>
if i click next page . the no contiune number 1,2,3,4,5
next page start from 2 it should be no 5,6,7,..
Ah so something like this
<th scope="row">{{ $loop->iteration + (($attend->currentPage() -1) * $attend->perPage()) }}</th>
As you are using the built-in paginator the first index can be retrieved from the ->firstItem() method:
<th scope="col">No</th>
@foreach ($attend as $data)
<tr>
<th scope="row">{{ $attend->firstItem() + $loop->index }}</th>
...
@rodrigo.pedra Very nice and clean solution. Always good to learn new stuff :)
Thanks @sinnbeck !
It happens that I used that this other day. Sometimes I doubt one can know all API by heart. Good for us Laravel docs are top-notch
Indeed. I remember alot, but not all. And some things I simply dont know :p
thank you for respon @michaloravec i really appreciate it. i will give you love tags.
@sinnbeck i just choose who reply the first my question. hehehe and you the first person. if it not work it i will choose @michaloravec . bytheway are you getting some reward maybe to answer many question in this forum? i mean real reward..
When I saw reply by @sinnbeck I knew that is wrong, so I added my own reply but I really didn't know that something like that is in Laravel by default, what was provided by @rodrigo.pedra
@meglo Probably in the future there will be some rewards
Check this out.
Yeah I misunderstood what you meant, so my first answer was way off.
Currently I just help out for fun. It is great helping out others who are struggling and it is a great way to give back to the community :)
@sinnbeck Yeah me to, but it's also good reference in CV :) And I want to be in TOP 3 :D
@michaloravec Well just are right at my heels, so I think it just a matter of time before you get there ;)
@sinnbeck Yes, but you've been it making it harder for me for the last last few months :D
Please sign in or create an account to participate in this conversation.