Pipelines were just introduced into Laravel core this past week. In this video I'll show you how to create a simple API using Laravel Pipelines. Enjoy!
Nice explanation! Why should I use this instead of just applying the "when" to my query builder directly? I think this makes the code harder to read with the pipelines.
Nice video, but I have a simple question, can we use the __invoke method instead of the handle method in filter classes? Cuz for me is fiilling like the __invoke method more clear.
I've always found pipelines processing fascinating, but I wonder how could I bifurcate the pipeline into 2 or more processes under some conditionals correctly, so far I've though to create new processing pipelines with in a pipeline accordingly to some respective conditionals
great and maybe you dont need to create filter class for each query parameters. Maybe you can parse request query strings and itrate them. Actualy this api is for internal using by developer such as datatables search etc... dev knows already query params. And I think you can manage with one filter class. Meanwhile it is a nice content many thanks.
My rule number one: NEVER use model methods in controllers. Controllers shouldn’t even know the models exist. Either use services or action classes, and of course, repository (believe it or not, there were times when i had to avoid using eloquent) But, excellent example anyway. You’ve used cpp and other stuff most PHP devs don’t even know of
Service classes are my go-to. I too avoid using Eloquent when dealing with "complex" queries. I started doing that after learning how Eloquent parses and builds it queries
I am so sorry Jordan I sad before anyone does not tell about service containers , providers , etc... I found you and I am watching your contents and you have contents for them. many many thanks
Maybe you can tell about dynamic database connection according to user profile.(it is so specific I know that many times we are making CURD apps and that apps so boring :) ) I have a project like that. I can covered it out in one week. coz I am new on laravel. Then I found my problem about it. Middleware sequences were wrong :) logic was when user register to main app than main app create a db for user than user login own admin panel and that panel uses to db of user. it was hard to for me via laravel :) by the way you can take videos about complex project in real life. I dont mean hard codding. The approching or create a application logics@@Daltoncast
It's a good explanation of how pipelines work in Laravel, they are basically the Chain of Responsability design pattern being applied using Laravel's contract. However this example should be used as an example only since it's totally unecessary to use Pipelines for such situation as building a query. In this case just use ->when() directly without pipes.