Simplifying Laravel: The Power of Single Action Controllers Controllers are there to make our lives simpler, not to make them more complex. However, even when we separate the logic out of our route files, sometimes the controllers themselves can also become cluttered. That’s one use case for a Single Action Controller. Laravel — P25: Passing URL Arguments to Controllers The Single Action Controller will contain a specifically named method: __invoke(). Naming the method __invoke() will eliminate the need to call it from our route. Instead, we can just call the Controller itself. Creating the Single Action Controller Creating the Single Action Controller is
Tag: Controllers MVC
Dynamic Data Handling: URL Arguments in Laravel Controllers Now that we’re familiar with creating controllers, we need to be able to pass arguments to it. This comes in form of URL parameters. Sometimes we need to pass an argument like a specific id. Laravel — P24: Controllers Intro If you haven’t created the TestController, it’s time to do so now. I’m going to be using the one from the previous article, but the artisan command to create it is: php artisan make:controller TestController. Creating the Route Our first task is to create the route. The URL will contain a parameter that will be passed
Navigating Laravel: An Introduction to Controllers For the past 23 articles, I’ve been screaming on the inside, since we haven’t been doing things the right way. Can all logic fall into your route? Sure it can. Should it? Absolutely not. This was my way easing you into Laravel. If you’ve ever read anything else on it, what’s usually the first example? “Alright guys, let’s create a to-do list.” That’s great, but it uses way too many concepts at the same time without going into enough detail about what everything else does. Enough of that, it’s time for controllers. Laravel —