---
title: Laravel + Livewire todo app (and so much more)
url: "https://aaronfrancis.com/videos/laravel-livewire-todo-app-and-so-much-more"
path: "/videos/laravel-livewire-todo-app-and-so-much-more"
type: video
author: Aaron Francis
published: 2024-05-17
topic: "Laravel & PHP"
keywords: [laravel, livewire, todo app, laravel breeze, laravel models, laravel migrations, livewire components, livewire state binding, mass assignment, email notifications, laravel queues, laravel commands]
youtube_url: "https://www.youtube.com/watch?v=oAUbpUcgGx0"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# Laravel + Livewire todo app (and so much more)

## Chapters

- Introduction: Building a To-Do App in Laravel
- Laravel Setup and Breeze Installation
- Exploring Laravel Starter Stacks and Dark Mode
- Logging in and Seeding the Database
- Creating the To-Do Model and Migration
- Modifying the Migration for User Association
- Creating the Livewire Component
- Binding the Task Input to Livewire State
- Handling Form Submissions in Livewire
- Fixing Fillable Attributes for Mass Assignment
- Displaying and Iterating Over To-Dos
- Associating To-Dos with the Logged-in User
- Deleting To-Dos from the Database
- Adding Email Notifications for New To-Dos
- Queueing Emails to Send in the Background
- Creating a Command to Handle Overdue To-Dos
- Scheduling Daily Tasks with Laravel Console
- Configuring Mailers and Other Drivers in Laravel
- Flexibility of Laravel for Real Applications

## Transcript

**Aaron Francis:** Building a to-do app with Laravel is, is very easy. I'm gonna show you one way to do it, and it's gonna take us just a few minutes. But you gotta understand, this doesn't really make a lot of sense. Laravel is designed to build real applications. If you wanna build a little, you know, toy with it, you can, but that would be like, uh, using a Lamborghini to go to the grocery store.

**Aaron Francis:** Possible, but not, not really what it's designed for. Let me show you how to do it. We're really starting at the beginning here. I'm gonna create a brand-new project, and we'll just call it todos. This is gonna pull down the Laravel framework and install it and get it ready to go. So now if I change into the to-do directory and use herd to open it, well, there we go.

**Aaron Francis:** There's our website, to-do.test. Now, what I'm gonna do is I am going to require Laravel Breeze, which is gonna set us up with, um, just a basic starter kit. So I'm gonna pull that into the application. We'll clear this out, and then we can say PHP Artisan Breeze install. And this is where it gets fun. These are all the different stacks that we can use for our Laravel application.

**Aaron Francis:** If you just want plain old Laravel Blade with Alpine JS, you can do that. There are two Livewire options. There's a React option, a View option, and an API only. I'm gonna go with Livewire functional API 'cause it's kinda fun, so we'll do that one. Dark mode support for free? I don't have to pay for this? Yes.

**Aaron Francis:** Let's do dark mode support. And I like PHP Unit over Pest, so we'll go with that. Of course, Node spit out some nonsense, so that makes sense. Now, if I run herd open again, and we look here, this is our website again.

**Aaron Francis:** Remember, we haven't touched a line of code yet. This is our website again. And look, auth, totally built in. So we can log in here. Forgot password. I can send a password reset link. I can register. All of this completely built in, already handled for me. I don't have to do a thing. So that's pretty nice.

**Aaron Francis:** In fact, let's go ahead and seed the database. So I'm gonna put one user in the database. So I'm gonna say, uh, let's clear this out so you can see it a little better. Let's say PHP Artisan DB seed, and that's gonna put one user in the database. Um, and so now I can log in to this app with test@example.com, and I think the password is password.

**Aaron Francis:** And look, now I'm logged in to an application. I've got my profile over here. I can change anything that I need to change or delete my account. And here is my dashboard scaffolding. We haven't even written any code yet. So I'm gonna start writing some code. I'm gonna create a to-do model and a migration. Laravel has an ORM and migrations built in, so we're gonna create both of those, and then we're gonna create the Livewire component that is the actual to-do list.

**Aaron Francis:** So first thing I'm gonna do is create the model. I'm gonna use the AR shorthand, which is just PHP Artisan. So I'm gonna make the model called to-do, and I'm gonna add this little flag that says, "Go ahead and create the migration for me," 'cause I need a database table to back it up, right? So we've got the model and migration. Let's go look at the migration first. So if we look at this migration, we see Laravel's gotten us off to a pretty good start.

**Aaron Francis:** Create a table called todos with an ID and timestamps. I'm gonna go ahead and let's associate every to-do with an authenticated user, because that's what a real app would do, right? So foreign ID for user class, and then we'll make a text column and just call it... What do you wanna call it? Task. Let's just call that the task there. And I think that's probably good for the table.

**Aaron Francis:** Uh, we can go ahead and run our migrations now. So now that table is in the database, and we're ready to go. Let us see. Um, let's grep for Volt. I think make Volt. So we're gonna create a new Volt component, which is, um, this is the functional API for Livewire. So let's clear this out and say AR make Volt, and it should ask us some questions.

**Aaron Francis:** That's pretty nice. Let's call this todos. And there we go. So if we open todos over here, we see we're given some, uh, we're given a function called state, and then we can do whatever we want. First thing I wanna do is say, "Hey," and figure out how to get this onto the dashboard.

**Aaron Francis:** So if I'm gonna open... Let's look for dashboard. This looks right. You're logged in. So instead of that, what I want is Livewire todos. So I'm gonna put that component there. So now I see hey on my dashboard. So I know that the component is wired up and living on the dashboard. Now we can start to actually write our little to-do app.

**Aaron Francis:** The first thing I'm gonna do is I'm gonna use this state function here, and I'm gonna declare task as, uh, a piece of reactive state. And then down here, I'm gonna start creating the form. We'll handle submit in a second. First thing I wanna do is input type equals text. And I am going to bind this input to that task variable. So I'll say wire model equals task, and then we can...

**Aaron Francis:** Let's go ahead and just dump out task down here. Um, let's add a little buffer there. And by default, this is not going to be reactive. Let's just go ahead and make it live just for this little demo here. So I can say hello, and it shows up right there. So we have our binding all set up. I'm gonna remove this live now because I don't need it to be live, 'cause what I actually wanna do is submit the form, not do some sort of live updating here.

**Aaron Francis:** So action equals what? What are we gonna put in the action here? This is one of the great things about Livewire Volt is you can just reference a function. We're gonna reference an add function. That's gonna be our handler. And instead of using action, we're gonna say wire submit equals Add. You could call this handle, you could call it whatever you want. So I'm gonna put add equals function up here.

**Aaron Francis:** So that is now our form handler. Doesn't do anything yet, but that's okay. And I'll put a button type equals submit down here, and we'll say Add. That should be good enough. And if we check back in the browser, we see it's not gonna do anything. That's 'cause we haven't let it do anything. So first thing we're gonna do is let's just clear out, um, let's just clear out the task, and we'll say, "This task equals nothing." So if we do that and we click on it, we see, okay, great, our handler

**Aaron Francis:** is wired up because we are changing that state. That task state is being changed. We're just nulling it out. But that's not really the thing we're looking to do. What we wanna do is we wanna create a new to-do model, and we'll just set task equal to this task. And then interestingly, it does need to be bound to the user.

**Aaron Francis:** This is the worst way to do it, but I'm gonna show you. Um, we'll say auth, and we'll just get the ID from the auth provider, and that should create the new to-do. This is not the best way to do it, and this is not going to work. Let me show you why. So coming back over here, test, add, and we hit this big scary warning. This is Laravel saying, "You haven't explicitly defined what attributes are fillable." And so to protect you from a mass assignment vulnerability,

**Aaron Francis:** you just can't put anything in there. So what I'm gonna do is I'm gonna hop over to the to-do model. I'm gonna come over here, and I'm gonna say, "I promise I'm being a very good boy, and you can just put anything you want in there." So by default, you could say, um, you could say, like, "Actually, I don't want the user ID to be fillable.

**Aaron Francis:** I'm just gonna be very careful, so I don't need that at all." Now, test, great. Maybe it worked. We don't really know. Let's see if it worked. Um, the other thing we need to do down here is have all of the to-dos. So if we say, uh, we can do for each to-dos as to-do, and then, uh, end for each.

**Aaron Francis:** And then we can just output, what do you wanna do? We'll do to-do, I think we called it task. So that should be something. Let's go ahead and just do a div here and a div there. And then we need to pass this, this to-dos, we need to pass that into the view. So we can do that with another state function called with, and we'll just say, with, um, to-dos as...

**Aaron Francis:** Not that one. To-dos as, what do you wanna do? We'll start by doing it wrong. So let's start by doing it wrong and say, "Return to-do all." Return all of the to-dos. So now if we... Oh, forgot a... There we go. So now we see all of the to-dos. And it's working.

**Aaron Francis:** So we have our to-do app. There are a few glaring errors, though. This is all of the to-dos, not the user's to-dos. So instead of doing, um, to-do where user ID, any of that, let's just go over to the user, and let's just say that the user, public function to-dos, return. This has...

**Aaron Francis:** We wanna say that the user has many to-dos. So we're just gonna say, "Has many to-dos," and that should be good. So now here we can say, uh, auth user to-dos. And that still shows us all of the to-dos 'cause we only have the one user, um, but this is specifically the user's to-dos.

**Aaron Francis:** Now that that relationship is there, we can clean this up a little bit. We can say auth user to-dos create, and now we no longer have to pass that user ID in. All we need to pass is the task, and we are in good shape. So we can continue to add those there, and now we have to-dos that are scoped specifically to the user.

**Aaron Francis:** The final thing we're gonna do here is we're gonna create a way to delete to-dos. So we will say that this is, um, a function that accepts a to-do as to-do, and then it just calls to-do delete. That's all, that's all that this function needs to do. We can make this a little bit prettier.

**Aaron Francis:** That's a pretty basic function. Let's add, um, div. Let's just add a button, wire click equals delete. And the thing that we wanna delete is the specific to-do. So we'll just put an X there, and we'll say, uh, to-do ID.

**Aaron Francis:** So we're gonna delete by primary key. Now if we come back out here, and we click on... Boom. Now they're gone. So those are being deleted from the database just like that. Is it the prettiest thing in the world? It's not. But it was very easy to do. And we could clean it up with some Tailwind if we wanted. Now, we've created our little toy application.

**Aaron Francis:** This is maybe good Twitter engagement bait, but this is not the extent of a real application, right? So let me show you a few more things Laravel can do that will help you if you're building real stuff, not just building engagement bait. So here we go. The first thing we are going to do is we're gonna create a new email. So we're gonna say, make mail to-do created. And so this email will be sent out every time someone creates a new to-do, which is kind of annoying, but hey, that's all right.

**Aaron Francis:** Um, so now in here, we can just say mail to auth user send new to-do created. And we probably wanna pass in the to-do that was just created so that this email message can reference that. That's pretty easy. We can just say- Right there. And so now anytime a user creates a new to-do, an email is going to go out.

**Aaron Francis:** Kind of annoying, but that's all right. It works for this example. Now, the problem is we're now sending an email as a part of an HTTP request, which is not super ideal, so we gotta figure out some sort of, like, background queuing system. And, well, this isn't a very long part of the video. You just put queue.

**Aaron Francis:** You just say, "Queue the email to be sent," and then it returns immediately, and then in the background, that email is going to be sent out. This is all first party. N- we, we, we haven't installed anything. This is all default Laravel. Now, let's imagine we also wanna send out an email every morning when there are overdue to-dos. We wanna, we wanna bug people and say, "Hey, you said you were gonna do this.

**Aaron Francis:** It's time to actually do that." Let's figure out... We can do AR::make, I think it's command. So we can make a command and say, um, let's do... call it overdueToDos. And now we have this overdueToDos, and we can come in here, clean up some of this, um, and we'll change this signature to toDosOverdue.

**Aaron Francis:** We'll say toDos where, and then you would put your date restrictions in here, um, and then we could loop through them and send an email, right? So for now, we're just gonna say, um, this line, uh, overdueToDos. And now we can run that by saying toDosOverdue.

**Aaron Francis:** And so now that's gonna, you know, in theory, loop through all the to-dos, looking for ones that are overdue, and create new emails to send those out. Kind of a pain, right? Because now I gotta come in here every morn- I gotta SSH into some server every morning. No, of course not. Let's, um, let's go to the console definition, and this just was here already.

**Aaron Francis:** We can go ahead and get rid of that. And instead of running this inspire command, we can run overdueToDos this way. So you can pass it as, you can pass it as a class, or you can say, um, toDosOverdue. You can reference it by the signature that you set up. So whichever one you want. We'll stick to this one for now.

**Aaron Francis:** So this is going to run the toDosOverdue command, but we wanna run it, let's run it daily, and let's run it at, um, what do you say? Let's run it at 6:00 AM, but 6:00 AM, uh, Central Time. So we'll say America/Chicago. And in fact, let's only run it on weekdays so we don't annoy people on the weekends.

**Aaron Francis:** Now, we have set up a schedule to run every single weekday at 6:00 AM to mail out overdue to-dos to your users. This is the kind of stuff that you would do in a real application, right? This is why Laravel is so great, because it is batteries included. And now you may be thinking like, "Oh, well, what, like, what mailer does Laravel use?" Well, that's interesting, because you can use any mailer that you want.

**Aaron Francis:** You can just come in here and you can pick SMTP, Mailgun, SES, Postmark. You can pick any of these mailers, and the configuration is already, it's already fully set up there. What kind of database do you want? Well, you just pick. By default, it's set to SQLite, but there's SQLite, there's MySQL, there's Maria, there's Postgres, there's SQL Server, if anyone uses that.

**Aaron Francis:** So Laravel is set up in a very driver-centric way in that it will handle doing everything for you, and then it will call out to the correct mailer or the correct database to do that external service type stuff. If you don't like Livewire, that's totally fine. This is not the only way to build it. You could use Vue or React with Inertia. You could use Vue or React with a pure API.

**Aaron Francis:** You could just use HTML and Alpine if you need minimal interactivity. The point is, Laravel has everything you need to build a real application, as well as a little to-do app that you can put on Twitter. If you wanna watch a little bit more about Laravel Octane, which is a way to run your apps even faster, I'll put a video here. Until the next time, see ya.

---

## Related on aaronfrancis.com

- [Laravel vs React](/videos/laravel-vs-react) *(Video · 2024-05-21 · shared: laravel, livewire, laravel breeze)*
- [Aaron Francis is putting PHP in Your JS Files](/podcast/aaron-francis-is-putting-php-in-your-js-files-6f3117a7) *(Podcast · 2025-03-05 · shared: laravel, livewire)*
- [Fusion: Write PHP inside your Vue and React components](/podcast/fusion-write-php-inside-your-vue-and-react-components-cdf3a9e4) *(Podcast · 2025-02-14 · shared: laravel, livewire)*
- [#33 - Aaron Francis on Fusion, TUIs and Content Creation](/podcast/33-aaron-francis-on-fusion-tuis-and-content-creation-087d6b18) *(Podcast · 2025-02-13 · shared: laravel, livewire)*
- [The Big Reveal](/podcast/the-big-reveal-675733cf) *(Podcast · 2025-01-28 · shared: laravel, livewire)*

## Relevant Resources from Aaron Francis

- **[Solo](https://soloterm.com)** (overview on site: [/software](/software)): All-in-one agentic development platform and terminal workspace built by Aaron Francis for orchestrating processes and AI coding agents.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `laravel` ([K-L](/llms/keywords/k-l.txt)), `todo app` ([T-Z](/llms/keywords/t-z.txt)), `mass assignment` ([M-N](/llms/keywords/m-n.txt)), `email notifications` ([D-E](/llms/keywords/d-e.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
