Replying to @ErringtonA
Only Beyond Dark Castle. I may or may not have indulged myself recently by showing my kids YouTube clips of it. Amazing. Especially the fact that constant two-footed standing jumps is significantly faster than jumping. What a game.
Unrelated: Cap’n Magneto, anyone?
1
1
Hey @gonedark and @laravelshift, just read the Laravel 8.52 weekly updates email (love them, thanks heaps!). Don't know how 🔥 this is, but here's what I came up with for your string->array problem.
1
1
Sample use case (which is pretty close to my actual use case, except for not being sensible).
PS: @themsaid, the preventLazyLoading feature is awesome! Instantly found a couple of N+1 issues that I hadn't found with other tools.
1
Replying to @laravel
@laravelphp peeps: I have a trait that helps me cleanly avoid the N+1 problem in certain use cases. It adds a smartCount('relation') method to any model class. I'd love to know if this is misguided - am I missing something?
Trait below, sample use case in the follow-up tweet.
2
1
Replying to @jamesmills @JustSteveKing
Whipped up a little speed test, purely for my interest (using a simple collection of arrays, so refactored the macro for that). Macro was consistently about 3 times faster, no matter how big or small the dataset. No idea how valid this test is :-)
1
3
Replying to @StephenLShead @jamesmills
And if you want it to be reusable, you could make it a Collection macro:
1
2
Replying to @jamesmills
The 'sort' suggestions are fine, though seems doing a full sort of the collection is overkill, right? If you just want to FIND the one with the lowest price and then add the 'cheapest' attribute, how about this? (If 'price' is ever null, you'd need more null checks.)
1
3









