Is there any function to add an item before/after a specific item in a collection #51749
Replies: 3 comments 1 reply
|
I have a similar problem right now, and while looking for a solution came across search and splice, but: search returns a key, and splice expects an index. This leads to unexpected results: |
|
You can use For example: $position = $collection->search('second');
$collection->splice($position + 1, 0, [$newItem]); |
|
I don't think you should manually verify the Passport access token using Laravel Passport already handles access-token validation through its authentication guard. You can protect your API route with Passport: Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:api');Then send the token as a Bearer token: Authorization: Bearer YOUR_ACCESS_TOKENPassport will handle the token parsing and signature/expiration/revocation checks for you. If you really need to inspect or verify the JWT manually, you should use a JWT library and verify it using Passport's configured public key and the algorithm specified by the token, rather than recreating the signature with So the main issue with the current implementation is that it is trying to reproduce Passport's token verification logic manually. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I need to add an item after an item in a collection. Now I'm doing like below. is there any function to do this? Or can I make a PR for this functionality?
All reactions