Laravel Models Unveiled: Your Gateway to Data Interaction After spending an entire article learning about migrations, it’s only natural that the next one is going to be focused on Models. Laravel — P28: Migrations What is a Model? A Model is just a class that ties into a table within the database. By convention, tables are plural and Models are singular versions of the table name. For example, the tests table should have a Test model associated with it. The Test model knows how to communicate with the tests table and can add, update, get, or delete data from the table. How does the Model know to interact

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

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 —

Controllers bridge the gap between users and databases We’ve made it past the basic MySQL functionality. I do want to cover normalization, and will do that in the next article, but I believe we need to introduce Controllers. It will simplify the concept when you start learning about Laravel, since it is an MVC framework. What is an MVC Framework? MVC stands for Model, View, Controller. I’m not going to go into strict definitions like something, something, business logic. Let’s speak human-talk. Model — The Class that interacts with the database. In our previous examples, this is the Author class. View