Stephen Shead (@StephenLShead) header
Stephen Shead (@StephenLShead) profile picture

Thinks Jesus is God’s news that everyone needs to hear - transforming love, joy, purpose, real hope. Mostly here for dev stuff (PHP, Laravel).

Sydney, New South Wales
Joined May 2019
Replying to @matthewmoffitt
Solution: Don’t write a draft.
4
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
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
And if you want it to be reusable, you could make it a Collection macro:
1
2