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
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
Haha, yes, it's strange! Almost all our sporting teams use green and gold for their uniforms, but it's not limited to sport. The examples below are pretty typical. But I think Tim's right - it would confuse everyone else. I can see how flag accents might be better.
1
Don’t normally post stuff with my kids but ... 16 weeks, 18,240 pieces. Came in 4 separate sections, but few mixed them up first - otherwise how could he really say he’d done an 18,000 piece puzzle? Epic!
1
4