Impressive! But I'm kinda curious, why having to wrap the query to get featured post in a resolve( ) - > handle() function? Please someone school me, what does that achieve when I can simply do Post::where('featured', 1) -> get()
resolve() is useful to initialize a class from the container and get automatic dependency injections. So any type hinted classes on the class being resolved is also resolved by the container and all the way down.
Even though this example is not showing it super right, that is about SOLID. This is really deep topic, so you have to dive into this by yourself. There is a bunch of information about it though
Good question. There are already some good replies too, but yeah you could write it like you do too. But sometimes getting featured posts is not that easy and you need to perform maybe multiple queries to find them. For bigger apps there might a lot of business logic to define that. Hope that helps 👍
Thanks for all the responses. I'll definitely check out Spatie's book on this same subject and also study more about SOLID principles as recommended. Thanks all, Laravel ❤️❤️❤️
This is a great feature. But if its support a 2nd parameter and it will cache base on that cache that would be amazing something like react useEffect hook.
Impressive! But I'm kinda curious, why having to wrap the query to get featured post in a resolve( ) - > handle() function? Please someone school me, what does that achieve when I can simply do Post::where('featured', 1) -> get()
This is a long conversation. I suggest you check Spatie's book "Laravel beyond CRUD"
resolve() is useful to initialize a class from the container and get automatic dependency injections. So any type hinted classes on the class being resolved is also resolved by the container and all the way down.
Even though this example is not showing it super right, that is about SOLID. This is really deep topic, so you have to dive into this by yourself. There is a bunch of information about it though
Good question. There are already some good replies too, but yeah you could write it like you do too. But sometimes getting featured posts is not that easy and you need to perform maybe multiple queries to find them. For bigger apps there might a lot of business logic to define that. Hope that helps 👍
Thanks for all the responses. I'll definitely check out Spatie's book on this same subject and also study more about SOLID principles as recommended. Thanks all, Laravel ❤️❤️❤️
Great one, but I'm foreseeing an issue with Octane
Laravel octane handles this by flushing the instance after the operation is terminated using the FlushOnce class
This is awesome, I've wrote something similar too many times to count for some static cache, using a helper is definitely smarter
That's awesome! Glad you like it!
This is a great feature. But if its support a 2nd parameter and it will cache base on that cache that would be amazing something like react useEffect hook.
Definitely a very good feature - at the same time, I hope it doesn't make people too lazy to check when something is accessed.
I love it 👍🏻👍🏻
We too ❤️
Thx!
No problem!
😍😍😍
I'm happy this is now a built-in
We are too 🙂
I said it Once and ill say it again. The real gems are the Laravel friends we made along the way.
So true!
You need a better host.
Who has the same energy as Laravel.