Evolving Your Laravel Projects: Mastering Migrations Migrations are a way for everyone on the team to easily share database schemas. Once you create a migration, everyone on the team will be able to run it and generate a new table. There is no more messaging others and telling them that they need to add a new column or change the column type. Upload the migrations and if something breaks, the team can run the migrations again to update the tables. How Do You Create a Migration? Generating a migration is just another artisan command. I told you that we would be using artisan a
Articles
Laravel Database Mastery: Starting Your Data Journey Why database and not a model intro you may ask. A model is just class that communicates with a specific table in the database. I’m a true believer that you should understand a topic at a high level before you jump into creating code for it. Let’s take a moment to discuss the database and how Laravel interacts with it. What is a Database? It’s not going to be that type of basic article, but just so that we’re all on the same page, a database is a place where you store data.
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 —
Efficiency Through Organization: Laravel’s Route Groups Explained Who could have guessed that there would be so much to discuss in routing. If you think this is a lot, there will be another 10 articles or so on just routing a little later when we get into more advanced stuff. We’re still baby-stepping through Laravel. I’m eager to get us into Controllers and Models, so we’ll do an intro into those next. Laravel — P22: Named Routes What are route groups? Route groups is a nice and simple way to reduce redundancy. Let’s say that we have the following routes: /admin/contact
Unlocking the Power of Laravel: Mastering Named Routes Routes change. “We don’t like contact-us; can it just be contact? We also don’t like about-us; can it just be about?” These are the kind of questions that you get from your amazingly awesome Marketing team that’s there to only make your life super simple all the time. Laravel — P21: Artisan Intro and Route List Does it matter that you have a ton of components that all have the route hard-coded in? How many <a href=”/about-us”>About</a> will you have to modify to <a href=”/about”>About</a>? Luckily, there are named routes. Once you set a name for your route, you
Laravel Essentials: Exploring Artisan and Navigating Routes I’ve teased the artisan utility a few times and now is the time to introduce it. We won’t go into it’s full functionality yet, instead we’ll build on it. The only command that we’ll look at in this article is the one that shows you your entire route list. Laravel — P20: Routing Methods and Redirects Artisan Artisan is just a command line tool that exists inside the root of your application. So, each time that you install Laravel, you’ll get the artisan tool along with it. Open your folder and you’ll see it there. If
A Guide to Routing Techniques and Redirect Strategies For this article, we’re going to stay in our comfort zone. Even though we haven’t looked at the artisan command yet, used Controllers, Models, etc, there was still enough content to write 19 other articles. There are going to be a few more written before we get to it. Nice and easy steps. Laravel — P19: Component Layouts This time, I want to explain our routes/web.php file a little further and the kind of stuff that we can do there. We have been using our router as our controller as well for many instances. I love
Actually Creating the Layout Believe it or not, the difficult part was covered in the previous article. Breaking apart the header and footer components was a tedious task. Creating a layout is simple. Laravel — P18: Component Layout Prep-Work Recap We first created the following file: views/layouts-test/index.blade.php. <!DOCTYPE html> <html lang=”{{ str_replace(‘_’, ‘-‘, app()->getLocale()) }}”> <head> <meta charset=”utf-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1″> <title>{{ $title }}</title> <!– Fonts –> <link href=”https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap” rel=”stylesheet”> <!– Styles –> <style> /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}a{background-color:transparent}[hidden]{display:none}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5}*,:after,:before{box-sizing:border-box;border:0 solid #e2e8f0}a{color:inherit;text-decoration:inherit}svg,video{display:block;vertical-align:middle}video{max-width:100%;height:auto}.bg-white{–tw-bg-opacity: 1;background-color:rgb(255 255 255 /