Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with looping over items #19

Open
ImprobableGenius opened this issue Oct 3, 2023 · 1 comment
Open

Issue with looping over items #19

ImprobableGenius opened this issue Oct 3, 2023 · 1 comment

Comments

@ImprobableGenius
Copy link

Hi, I was trying to use this package in one my projects and I noticed that in breadcrumb.blade.php component you are accessing the items() method as a variable. If I die and dumb the $item variable it returns an object instance instead of an array.

This works when you loop over the object for reasons unknown, however the $loop variable inside the loop does not have proper values for 'remaining', 'count', 'last' and so on.

I was able to solve this by using $items() instead of $item.

I am pretty intermediate in my knowledge relating to Laravel and Blade. I am just looking to see if I am missing something here.

Thanks,
Aarish

@ouun
Copy link
Contributor

ouun commented Dec 6, 2024

Just stumbled over the same. The $items var is an object Illuminate\View\InvokableComponentVariable in the blade view.
I don't think that this should be the case, however you can just collect it and transform it to an array in your view. Then you can use $loop->last as expected.

$items = collect($items)->toArray();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants