YouTubevideo· Dec 14, 2023· 3:36:38

The Complete TALL Stack Tutorial - FROM NOTHING TO PROD (Tailwind, Alpine, Laravel, Livewire & More)

Watch on YouTube ↗

transcript

502 moments
  1. [Music] I've been building in the tall stack for almost two years now that's Tailwind Alpine larl and larl Livewire and my productivity and speed to push things out has gone through the roof and I want to create a simple tutorial going from nothing from scratch from zil from NADA to production ready live application and teach you how to do it along the way so this tutorial is something that I wish I

  2. had when I first started learning the toss stack because there's so many things that come out of the box within laravel Kon Q's emails everything like that that just makes sense that's just magic and I want to be able to highlight that but then also highlight some of the newer things that Lille has to offer right now volt single file components um and then just lar of a live wire and some component libraries as well so let's dive

  3. [Music] in so the application that we're going going to um actually be building is called note share and we actually call it send notes something like that when we start building it out um but the premise is simple you'll be able to uh this is actually live in production and we'll build something and it might look a little bit different we might have some different features just as we go along but I want to start from nothing

  4. and get to this within a couple hours Let's Do It um so anybody can register and log in um and I'm just going to log in with the the uh the username that I created and the basics premise of this is um I like to send my wife notes every single morning so um I'd love to be able to create a note have a perfect subject of like hey

  5. hope your day goes well um send like the actual subject of a note and then tell who to send it to so for example I would send it to me the next day and then you can say okay when should this note go out so if I said hey let's just have it go out tomorrow so when you schedule that note what's happening is um every day at 9:00 a.m. eastern it's going to send all the

  6. notes are scheduled across all applications and they would get a private little link that says hey um not private it would be public link that says hey here's the note here's who it's sent from and then you'd be able to Heart it and everything like that so if I was to you know go back to my dashboard I could see how many hearts people have sent how many notes I've sent and I'd be able to see when they when it has Ben sent if that makes sense

  7. and that's that's it there's a lot of things that are kind of going on underneath the hood of this application but I think the premise of this and some of the features that we'll be building uh really just speak to how easy things are with Lille and hopefully how fast you can be with Lille laware so so this tutorial is meant to be for people who um are starting out who have not touched larl at all and for people who have touched larl maybe you'll learn some

  8. things along the way I'm not an expert developer I'm not someone who knows all the ins and outs of laravel and the best practices and everything like that but I I have learned how to build an application in a way that works for me and that's what this application that's what this tutorial is all about so I'm going to kind of start from the be beginning start from the basics um you might know some of these things and you might not you might have PHP and lville set up you might have already done it

  9. the premise of this is if you have experience or if you don't hopefully this tutorial will give you some groundwork of how to build an application from nothing to something so let's do it let's start off with actually installing larel so the first thing that you were going to want to do is make sure you have like a a a way to run larel on your machine easiest way if you're on Mac is going to be laravel

  10. herd if you are not on Mac let's see um it's there's a couple different options so sale is basically like a Docker system that you can do on Windows there's also something called Lon for Windows um I would check that out as well and if you're on Linux you probably already know what to do um and we're going to be using something called wi UI and basically this is just an easy way for us to get nice looking components

  11. out of the box with without having to you know mess around with custom tailwind and spend most of the video doing that this is basically just component Library using LEL live wire alpine and Tailwind so why don't we uh why don't we get started I'm going to open up my terminal and the basic command that you get out of the box with laravel herd and if you

  12. installed largon or um just like that that Docker Library is going to be the composer larl or it's just larl so laravel new and I'm just going to actually let me go into my um sites folder and I'm just going to do larl new um send notes and that's going to be the name of our application right now we're going to start off with laravel Breeze and I'll show you what this is in a little bit but basically larel Breeze is

  13. a starter kit that gives you authentication and a few other Nifty Things like hey here's a dashboard page here's a profile link just all out of the box so let's go ahead and do that lar Breeze I'm going to use the Live Wire volt class API you can follow along with this tutorial using the uh functional API using something like react or view with inertia but I'm going to be using the

  14. class AI just because it's a little bit more familiar with people who are familiar with PHP um if you come from the JavaScript world you might find yourself being very very attracted to the functional API I do like it but for the premise of this tutorial I'm just going to stick with the with the class API Live Wire volt class API and basically what volt is a single file components in Live Wire very familiar to the react World for example where you'll

  15. have all your server server functionality in the top of the file and then your view functionality in Bott files so that way you're not having to it is collocating those files um we're going to say no for dark mode support just to make it a little bit easier uh we'll do we won't do any tests in this particular video but we'll do we'll select Pest and then I'm going to initialize a g

  16. repository perfect and now like I said the premise of this video is to get us up and running as quickly as possible so I'm going to try to do as little Cuts as little editing as possible just so that this feels very familiar very fast-paced very um you know how how would this look like if you building something like this in a

  17. weekend in a night in um in a week day on whenever you have free time to learn L to learn Live Wire to build an application that is ready for production that can scale with the services that we're going to be building on with the packages that we're going to be using it's not something that is just a you know a fun little tutorial fun little product to build this is something that

  18. you can start using in Productions start being ready and hopefully you'll be able to find out you know different ways to build an application that works for you um we're going to use the SQL light and in production we'll use postc because we're going to deploy to fly.io um just because it's the easiest way at least uh right now for me I think it's the easy way to kind of get up and running um none of the services none of the um

  19. applications that we're going to be building or any sponsored or anything on this video it's just stuff that I like to do use and stuff I can get up and running I also have a lot of applications deployed on laravel Vapor which is lille's service for AWS but it's a little bit more complicated and this video and fly has a generous free tier which is awesome especially for this video so you can deploy this for free you don't have to worry about paying anything I think fly does say

  20. that you have to input a credit card but we'll we'll get we'll get there when we get there so let's go ahead and get into our send notes folder okay and we're ready to go few things that we have to do so we have a git repository all set up we'll create a new GitHub uh repo um here in a little bit um but what we'll do is we'll go ahead and run npm

  21. run Dev that basically starts the development server using vit um and then a new file folder I'll basically just say or new terminal file I'll go ahead and um just kind of have that ready but basically now we can go to send notes. test and we have our larl application up and running so I'm going to go ahead and remove this and this is basically just

  22. everything that you know it's it's the breeze install out of the box so we have things like login and register and before we go ahead and try logging in register you know these Pages can can but we don't have a a database set up just yet so what we're going to do is we're going to go ahead and run PHP Artisan migrate now what this does is it gives us the option of creating a sqlite database so that we don't have to worry

  23. about that we can just say yes and now our database is ready to go so if I was to hit register and create a new user then we're ready so I'm just going to save that just so it's easier just log in in the future but yeah we're ready to

  24. go we have a user we have a dashboard we have things are just kind of ready to go for us and we are you know it's been what 8 minutes um yeah so it's pretty great to be able to have something like this ready to go out of the box for us without having to do too much work um but yeah let's set up a GitHub

  25. repo and let's get going so um let's go ahead I'm going to log in in GitHub all right now I usually have um the GitHub CLI up and ready to go but the logging is going to be the easiest just because so we can kind of just do it all from scratch that way I'm not not doing taking any shortcuts to make this video shorter or anything like that I

  26. want to make sure that we kind of give it it's due justice of saying hey this is what it takes to create an application get it published and ready to go um so I'm just going to create a new repo we're going to make it public and we'll call it um send notes let's see looks like it's stalling on us real quick there we go so send send

  27. notes awesome um a way to send schedule notes to your friend Z there we go public and create repository so now let's just get this ready get this out of the gate um push an existing repository go ahead and copy that and we'll push this in okay we should be ready to go awesome there it is there's our larel

  28. Breeze application ready to go with PHP okay now let's deploy this I like to deploy as early as possible just to make sure that everything that we have Within in this application is you know doable and that way we can set up some CI and CD to make this a little bit easier for us in the sense that anytime we push um a commit to this repo this send notes

  29. repo we'll be able to just see those changes live on fly.io so let's go ahead and let's do that so I'm just going to um log in to fly right here and I believe I'm signed into GitHub so let's go ahead and do that if you don't have a fly to IO account I I would recommend creating one I think it's the an easy way to get up and

  30. running so let's just go ahead and see um how we do this so I know that uh fly has a great um kind of documentation for Lille so let's just go ahead and build this out so I know that you can install the fly CTL CLI that's the easiest way to do this because I've already I'm already locked logged in I'm ready to go and then we just run fly launch in our repo

  31. so let's go ahead and do that fly launch awesome so I detected a laral app um it has you know send notes drive from the directory name L LA uh most apps need one gigabyte of ram um uh we we'll create a postc database

  32. later um just to kind of have that ready uh but so first off we'll um we'll just say do you want to tweet these settings before proceeding um let's actually see if yeah I don't think we have to do anything just yet so let's go ahead and say

  33. no awesome so it's kind of building it out for us I know they recommended um Fly launch if we ask to Ploy down we'll say no and then we'll add some uh we'll add some variables to our fly. toml file um add some any secrets that you have can be added here and then we'll go ahead and create a postgress database so that way we can just be

  34. logged in be ready to go within fly IO as well so let's see how this is running um but when we log into post cres this is what we'll kind of attach it to so I'll kind of speed this up a little bit so that way we're not waiting too much awesome so it's deployed and we can uh we should be able to just open this link and be ready to see our application and there it is now we're not going to be

  35. able to log in because um you know we we haven't yet set up the postes database so let's go ahead and do that now so Lille and postes um so first we're going to do attach postgress um I believe believe we have to create it first so let's go ahead and do that um to run yeah so let's go ahead and follow

  36. the guide here to create we're just going to say fly postes create let's take that command and plop it in here and we're just going to say this is uh send notes we'll just say PG I'm going to um put it in LAX cuz that's where my application is running as well and then um let's see we'll just say

  37. development and we're going to scale it down so fly. I has the ability of saying okay after 1 hour of no um no connections let scale it to zero and we'll say yes awesome so we have a post cres database within our fly.io account so let's go ahead and connect it so if we go back to um this application we'll be able to connect postres to our larvo

  38. application so let's go ahead and do that and I already had um a I already had A's I already had a um postes database connected to my fly. AIO account so you should only need one I have two running now but you should only need one um so let's go ahead and connect it looks like I have an error let's see so fly postc attached let's

  39. see what this gives us again I know I know it threw an error last time see okay yeah so accepts one r z received post attached so we should give it the postrest app name so if I believe if we did um send notes DPG so we should be able to um perfect yeah so we uh post cluster

  40. send notes to PG is now attached to send notes perfect um and I'm going to delete this so don't try to uh don't try to connect to the database because I'm going to delete all this after this video gotcha um sweet now one of the things I want to kind of point out is you know you have Laro herd and you have the fly CLI but

  41. one of the things that I think helps with being able to um have these kind of features is is there is the tall stack um tall stack p package uh which kind of includes everything that you might need for within vs code now if you're using like PHP storm or Vim or whatever you're doing you probably you're probably smarter than I

  42. am so you'll be able to know which extensions you need but this gives you intellisense for both larel intellisense for live wire alpine and then tailwind and then also PHP intelence which is going to be code intelligence uh for within PHP so those are the two that I would kind of recommend I have a few others but those are the two that do the the heavy work I should say um so let's go ahead and look

  43. into our fly tummel and here we go so we have um you know we have our app send notes um and then we have some of our n environment variables and then we have the HTP service I believe it recommended um adding something else so app URL so let's go ahead and add that and since we

  44. know that this um since we know that this is going to was send notes. fly. deev let's take a look make sure we're doing everything here make sure the fly Tomo relab app uses postres okay so let's go ahead and go here I believe this is sent in the end okay so

  45. perfect um yeah we don't need this awesome and then we've already connected perfect so we should be able to run fly I believe it's called fly uh launch fly deploy and then we should be good to go so let's go ahead and run that um but first let's go ahead and take a look at

  46. our GitHub and we probably don't want to run this fly tummel file actually we might be safe because let's let's take a look we're not actually saving any kind of like sensitive information here so let's go ahead and let's just commit it so we'll we'll say um get

  47. uh at all we'll say this is um prep for fly launch awesome and we'll go ahead and push it we'll go ahead and set up GitHub cicd to to fly after we kind of set up this postgress database but we'll go ahead and fly deploy just to make sure that everything is ready to go for the postres

  48. database now if we were to take a look at our um Fly uh dashboard here we should see a new application kind of ready to go um and if I was take a look at apps you kind of see I have a few other things but this is send notes database and then the send Notes application and basically the send Notes application gives you two machines to say hey um you

  49. know that way it's kind of uh has a little has a little backup but it's it's running two machines connected to one postc database and fly is great because it has the ability of using SQL light if you would like or just running an application in the cloud using postgress so let's go ahead and take a look at what's run running looks like everything's good to go and let's go ahead and check

  50. so um we let's go ahead and register we'll say John Siri and we'll log in and we a server eror so let's go ahead and see what's happening in our dashboard the cool thing with fly to IO is actually gives you um gives you monitoring kind of out the

  51. gate so we should be able to see yeah there's no table okay there we go so the great part about Lille is we haven't actually migrated anything in the application now what we could do if we were going go to lille's flies documentation is this post deployment tab we could you know sssh into the console and then we could run our um we

  52. could run our PHP artist is in migrate which is basically the command within laral to take all the migration files that you have and we'll go ahead and take a look at that so we have um we have these migration files on the database here we have create users create password create fail jobs create personal access tokens this is given to us out of the box within LEL breeze so

  53. when I ran that PHP Artisan migrate a little bit ago locally it created a SQL like database for us with everything kind of set up so anytime we create a new migration a new um a new file to add something to the database we can run PHP Artisan migrate and that's just going to keep the database in sync with the files that we've created so we ran that locally but

  54. we haven't actually ran that you know in fly. IO yet um so if I was to take a look and let's see uh yeah post deployment right here so I to take a look um I know that uh l d there we go so we can definitely SS H into it and run PHP

  55. artist and migrate or there's a deploy release command which is basically that's going to be the easiest way so let's go ahead and do that so if we are going to go into our um vs code and we go into our fly tummel there's a deploy I don't think we're having a deploy command yet so we'll go ahead and add this here and there we go so let's

  56. go ahead and send this up to fly and what we'll be able to do is um Fly deploy and what this should do is allow us to run that migration so that yeah yes we're we were already connected to the to the database that we set up but now the database actually has the tables that we need to run LEL

  57. Breeze awesome now we should be good to go so let's go ahead and head back to our send Notes application and let's register Josh bam awesome we're good to go so let's go ahead and push this get commit so we're

  58. we're we're ready to go we have lbo Breeze up and we are running on fly. deev so things are things are starting to look pretty good so let's go ahead and let's go ahead and make sure we commit this we'll say this is post U deploy commands or

  59. migration there okay now we are ready to start building this application and one of the first things I love to do when I'm starting to think through okay how are we building this application what are the things we need the first things I like to think through is what does the application need to do so that way I can run as few migrations as possible because one of the things when you think through how your database is set up what you actually need to you know have prepared

  60. for when you're building this out it it helps to kind of have an overarching sense of what does the application need to do what are the things I need to look out for and then what is the database structure and the application process look like so let's go ahead and create a new note just to kind of like put everything out on paper so we'll say this is the um this is send

  61. notes tall stack perfect so what should this application do so first of all it should allow users to uh log in and create accounts and the great part is like that's kind of already been you know that's kind of already been like set up for us with their L bre um next users should be uh or we'll say users can type up notes

  62. and save them okay so that lets us know that there should be a way to save notes uh let's see notes will be sent publicly via email to view and then the receiver can heart a note a sent okay so this kind of tells us that the this kind of tells us

  63. the structure of what the database should look like and just like what we need to keep in mind as we're sending this cuz we we need to have things that aren't accessible um or are accessible even if you're not logged in we need to think have things that are only accessible if you're logged in only if you're a particular user and that's why I like to think of through as well as like what what are the things we need to keep in mind security aspect so like what should we keep in

  64. mind well um in terms of security users can't view other people's notes they should only be able to view theirs you know that's kind of security in a nutshell that you you should only be able to view what you're allowed to view and then uh notes should only be

  65. um um like not should probably have a way to be public I think so if you're sending them you probably are already making them public but maybe we don't have them be public until they're sent then we can mark them as public just in case what if you want to you know create a note um as you create a note and view it

  66. or there should be a way to view notes only if they're public and then maybe uh the last thing to kind of keep in mind I would say is that we want to make sure these notes aren't easily you know there's not an easy way to kind of try to view a note that isn't related to

  67. you so notes should be as secure as possible for public facing notes now we can't like tighten this up too much unless you want to have the viewers who are viewing this be able to log in via email and then view this note but one of the things we can do

  68. is um use uu IDs now this is a great way to say okay instead of uh you know my note being note number three that I'm sending to someone it's going to be note number you know 003 D FD Das whatever so that way it's very it's a lot harder to guess you know what is

  69. someone else's note they might have sent privately in some way to someone else yes these notes are still able to be accessed by anyone but you would have to have the link so it makes it a little bit more secure in that aspect now some of the things that we're going to learn and this is for those who are new to laravel those who are new to building out full applications and those who are not new who are kind of building this out these are the things that we're

  70. going to try to touch on you know we kind of already touched um what are things we are learning so we already kind of touched that we already learn like L about Breeze right that's that's what we uh created and we also have deployed right now we are going to learn about um models migrations we saw what was kind of built out for us in LEL Bree but now we're going to create our new a new migration

  71. and and do that we're going to be able to send emails and jobs background jobs be able to send those emails because we can't rely on the server to send them all what if we have 100 users and we want to send 100 emails all at once and it's possible but a background job helps that so we're not relying just on a Crown job or if we on

  72. um and with this background job we also we can also say this is um both uh q's and Cron um and then we're going to just learn basic routing as it applies to larl now if you're coming from the JavaScript World we're not going to be doing file based routing we're going to be doing PHP larl kind of standard routing now we're not going to actually touch

  73. controllers just of the way we're going to be building this application it's going to be a little bit more modern in the sense that we will be using um single file components and using the majority of that to send data to our application of retrieving data and then also pushing data into our application um and then

  74. also uh we'll probably just touching on that we'll we'll look at um uh policies so this is the security aspect who can view a note and then lastly um Live Wire volt so this is that single page component this going to be really familiar to people who are used to JavaScript files whether that's view or react server components where you kind of have your server hey I'm querying in

  75. the database or I'm pushing data to the database um in the same file that I have my view my view layer and I think that's pretty much it um so yeah let's let's go ahead and start building so users can type up notes and save them so what that means is is uh

  76. we're going to create a new migration and create a note for that migration now what this is doing is we need a way to save notes to the database now if you haven't worked with an NBC architecture um before model view controller this is kind of a a brief look into it now we're going we're really only be touching like the model and view part and I'll throw

  77. migrations into that as well but let's go ahead and go to our terminal now here's the command that larel kind of gives you it's PHP Artis and then we have a whole bunch of different things that we can run after that we're not going to into all of them but PHP artisan make and we're going to make a model now we're going to make a model of a note so when we make our model the the

  78. wording how we word the model is going to be in the singular so note instead of notes but the migration is going to always be in plural and so larvo actually does this out of the box for you- m is going to be migration so we're just going saying hey we're going to make a model of a notes that way we can store like the methods that we need in that model and then we're just going to create a migration with it so that we can add this to our database of course

  79. you can do all this separately you could say make migration ad notes column and you can there's a whole bunch of different uh standards that lay kind of expects or that's just kind of best practice but I like to start with make model and there's other things that you can kind of add on in this Dash um you know command you can add a factory to create notes for you you can add a

  80. controller or resource controller and we're not going to touch those today but so let's just go ahead and create note model and then create an migration with it perfect now let's go ahead and go into our vs code and let's take a look at what was created so we have our database migrations just create notes table then we have our app models note and we can see here in our user that it

  81. kind of has a couple different things it has this protected fillable method that just means that okay anything in here can be filled in by the user at some point in our application it's available to be filled in we have our hidden so this is things that are never going to be displayed to the user in any way shape or form and then these are just a cast

  82. specific to um the model within the the database model and so we have our note it's blank right here but we're going to first create the migration for that note so let's go ahead and create notes and we kind of already thought through like okay what do you need within notes well you first probably are going to need a

  83. uh a string of we just say this is let's say subject we can call this we'll call it title so if you're sending a note to someone yes you have a subject but we'll just say title so that way we can display it and call it title for that and then we're going to say that we need a body so we'll say and actually for this we'll use text so text is going to

  84. be like a long form and we'll say this is the body of the note and we'll have um a we'll have a date and we'll have this be a send date and we'll make this we don't need to make it nullable I was going to say we can make it nullable just in case like you're not sending it

  85. or kind of just saving it and maybe you want to send it at a later date but the purpose of this nose is to be able to send it to someone so you can pick a date and then we'll probably we have a um a Boolean of is published and we'll kind of set this to default of false and then we'll go ahead and create

  86. an integer and we'll have this be heart count this is what um we actually have that default to zero so the premise of this is being able to say okay we have a title we have a body we have a send date uh we have the ability to make sure a note is published or not um and I I think this is kind of um you know standard practice within

  87. lay of applications and maybe just within database applications in general is that is uh PR preface to um we can technically just call this published you know if it's published it's false if it's published is true but we'll just say is published and then Lal gives you timestamps an ID out of the box now we did say that we're going to change this to UU ID so that way it's a little bit

  88. more security focused so we'll just say uuid and we don't have to change anything else that kind of just gives us everything we need uh in our model we can um say that this uh should use has uu IDs and that's it that's that's all we need to do so that way the next time a

  89. no is created it creates it based off of uid now um let's go ahead and go into our terminal and we'll go ahead and go ahead and run PHP Artisan migrate now again that's to basically sync the database with the changes that we made in these migration files and we have a notes table and one of the things I like to do is if you come from the JavaScript

  90. world you're used to something like um like Prisma Studio or drizzle Studio or whatever yeah your preface your your your personal Studio table editor of choice and since we're working just with sqlite databases we just can use something like a gooey for reading database files and I'm just going to use table

  91. plus cuz that's the thing that I'm most familiar with so let's just go ahead and grab that out out so I if I opened uh table plus what I'll be able to do is let me just do ahead do this on a different screen and I'm going to open up uh sqlite database I'm going to um we'll call this

  92. S Notes we can select a specific file and in this database we're just going to say that this is for send notes and database database.sql light open it up connect and we are good to go so you can see here that we have a note uu ID title body these are these are all the tables The Columns that we created

  93. within our application now um one of the ways that we could kind of we could definitely just enter all of this manually if we want to but let's let's just go ahead and just leave this for now I'm not too concerned about about creating something um out of the box but we could give it a title we could say um you know first

  94. note um this is my first note we'll say this is um you know 12223 default false default okay now if we save this oh notes. uid okay I was having some issues um creating a new note because

  95. silly me I did not add the ID name to um to this to this migration so we didn't actually have an ID in our database column so what we can do now is we can going to exit this out we can run PHP ours in uh first we're going to roll back that basically is just going to um

  96. delete the create notes table and then we're just going to run PHP Artis migrate again and now we have a new notes table now we can run a database query to kind of input this in we could also create a factory which is basically a way to seed the database but for now I'm just going to use something called laravel tinker and that's basically just kind of a CI command that kind of gives you out

  97. of the box and we're basically just going to create a new note using the CLI if we were to run um PHP Ys and Tinker now we can run note equals

  98. new and now we have note title equals first note we have note body equals we have note send date

  99. equals and then we have uh is publish and uh integer is already new so we'll just go call note save perfect so if we were to open up our um if we were to open up our database our table plus which kind of has our send notes database if I was to

  100. pull this over and look into notes we should have a first note there we go now because I actually um identified that uu ID table as ID we actually have um a uu ID ready to go so I could modify any of this and we would be able to query this from anywhere in the database so we have his published to one we could set our hard count to 24 all

  101. this is mod modifiable and ready to go but before we do that we need to make it modifiable in our application as well so we probably won't actually open up table plus that much anymore because primarily anything that we're going to be doing with a database we're just going to do in larel in live wire on our view and basically that's usually what you're used to within a JavaScript application for example so if I was to open up this

  102. note model um we have protected fillable this basically says okay hey any of these uh you know Fields within the application are able to be filled and you know and we don't have any of this so we we don't need to make it like that um

  103. but it's a way of kind of making sure that only things that you want entered into the database or changed or updated or created are done there and but but there's another way you could do this we could do protected guarded and basically what that means is if we have this kind of set then anything can be filled unless we put it in here so protected guard ID we don't want someone updating their

  104. ID but everything else should be ready to go now we forgot one last thing before we kind of push this up into the database and kind of just have our our everything ready we're actually going to roll back that database um again PHP artison migrate roll back because we forgot one thing we need to make sure these notes are associated to a user now in the create notes table we're just going to modify this and we could create

  105. a new migration kind of add this colum but because we haven't actually started publishing any data into it it's not live we're just going to do this in the old migration so we can add a foreign ID and we can say that that's for user ID and constrain basically just means that that hey the user ID is going to be linked to ID of this notes so it just makes it a lot easier we don't have to

  106. create you know we don't have to create a user ID a column or anything like that just it just does the connection for us and we can also just call uh Cascade on delete basically that just means hey if the notes or if a user was to be deleted let's delete all their notes as well and there that just gives us everything

  107. out of the box so that if we were to um let's go ahead and just say phpr is in migr again then we're creating notes table perfect and let's go ahead into our notes model now here's where we can start to call pretty cool methods and we can basically want to say that okay GitHub cop are kind of doing our job for us public function user we just say um hey this belongs to a particular

  108. user and then in our our user model we can do the same thing we can say uh public function notes return this has many notes and that's it so if if we were in our code if we were in our Live Wire single file components and we'll get to there in a little bit we could say Okay whoever is the and Lara has awesome functions for this whoever is the O user so whoever's the logged in user we can get all of their notes just

  109. like this um notes and then that way we can kind of grab all the notes and loop through them or we could say you know Au user um uh or Au yeah Au user note notes create and then we're all sudden we have the ability to create a note that's linked to this user without having to

  110. manually fill in the user ID of whoever's logged in and we can do the same thing of like okay if we have a note what if we want to grab the user's name associated to that not we could just do uh you know note or we could you know like if we have the note being passed in via S ID we could say you know the note user and

  111. we could say name and all of a sudden we have you know whoever that name is what's associated to that particular note so just this just gives us a lot of cool functionality on the box and that's basically what model are for not only are you kind of calling yours particular um the abilities that you have within a model and this is something that you know it's it's different for us JavaScript developers or or people who

  112. you know who came from the JavaScript world because a lot of times you didn't really have the need to have a model it just kind of lived in your code it was state that was managed by your code or or by your database and it was kind of just in limbo and within models in this model view controller aspect you have the ability to kind of say Okay I want to create these new functions just to make

  113. it easier for me like if I was saying okay like um if I if I want to say like public function uh you know published notes and I want to just get all the notes uh from a particular user let say if I want to uh um if I want to say that this belong to a user then I could say okay you know copilot's

  114. making this easy but if return all the notes or the user ID is related to the user I'm passing in and only the ones that are published and just makes it a lot easier so you're not having to write stuff like this these methods over and over again you just put them in your models so that way you're you're you're kind of keeping it all in one place I do the same a lot for almost almost every single application I build if I going

  115. into users I say know like public function uh super user or admin or whatever that might be and I can return particular user that is within an array of emails that way I can say Okay um I only have one place where I need to change that code but anywhere in my application where only super admins can make this change

  116. now it's automatically Chang I don't have to search and replace every single aspect of my code okay we created the user we created the notes table let's just go ahead and start building and before we get into that we're just going to do one more thing we're going to um we're going to go into our uh notes so we kind of

  117. uh we we'll do this so we'll just say we we created created the models and migration so we're ready for users to do this to type up notes and save them but now we we're going to get started on uh the views aspect and before we get into that I want to uh start installing wire UI and this is mostly just so that we have an easy way of scaffolding out buttons and form fields

  118. and everything like that without having to manually specify them within tailin CSS and we already have tailin installed into this dashboard so if we were to go um into our dashboard. blade. PHP this is just if you're not familiar with blade it's basically just a template language where we can say anything here we could say

  119. you know H1 hi there folks and this just has tail one already built in for us so we could say you know text uh for XL and then if I was to go into our um oops if I was to go into our uh send notes. test and dashboard there we

  120. go but let's go ahead and install wi UI so um we'll go ahead and type in that composer require wi UI wi UI and this is basically again that's just a component Library to make things easier it gives us things like buttons and inputs stuff like that and if you wanted to you we have um larel Breeze kind of gives us components out of the box for things

  121. like buttons and inputs and stuff like that I'm not as familiar with them and how to use it as I am with something like Yi so I'm just faster and I that's something that I prefer we'll get into all these views folder structures here in a little bit but first I wanted to um just kind of finish uh installing this so we have yui we're just going to add the yui tag on the page head and this is where we can talk

  122. a little bit about um what these files are so we have views if we were to go into our routes web this kind of just says what views are being displayed so we have a dashboard and that is giving us uh anytime anybody accesses slash dashboard we're going to give the dashboard view we're making sure that the middleware is off and

  123. they're verified the email address is verified and we're just having a name a dashboard that way we can use it in our application same thing with profile now you might be thinking okay but is is that all the you know that that's where all the routing is right now so if we were to go into dashboard you know this is the views dashboard. HP that's what's

  124. being called right here um and then we have our Live Wire pages and these are basically what the volt single file components that we kind of installed and chose when we chose larel Breeze we have um welcome navigation we have our profile so if we were to go into our profile.php you can see here that we have specific Live Wire components you can think of

  125. these as react components in a blade a templ Time template so we have you know two or looks like um three different react components here not react but live wire single file components so we have profile update profile and here we have you know our blade component our Live Wire component

  126. so this is all server code and then down here we'll have specific views related to that code I'm going to go ahead and zoom out just one more just to make it a little bit easier and then we have um you know a layout which is this is where we're going to add uh this is this is a navigation layout and then we have um layouts for both our application as well as guest so guest is going to be

  127. people who aren't logged in this is the layout default layout for any view that we create that is not application and we can actually call that or no matter what so you can see here we have Dash board view we have X Ash app layout okay that just means that we're using the app layout where if we were to look at welcome this would be using

  128. um okay looks like no one's nothing is using that that guest layout but actually I believe the the oth is using it so I don't think we see uh yeah oh there we go log in um you can see okay here we go yes layout layouts. guet so this is just saying hey any login pages are going to be using this guest layout and we can

  129. create any new layout that we want to here um but basically what we're just all that to say this wire UI um that we need to kind of add we need to add it to our layout page and since we're going to be using this across both let's just go ahead and add it to um our Apple a layout and then as well as the the welcome

  130. page so app layout just going to add that right in there yui scripts okay perfect and then we need to add a couple things to uh Tailwind so Tailwind config um we need to add this content and then we also

  131. need to add require for presets and looks like that have presets so I'm just going to grab this cuz I don't have any presets yet and then we should be good to go now there's one more thing and this is just because we're using um this is just because we're using larel Breeze is we need to publish some config files because larel Breeze gives us a drop down component and yui gives us a drop down component

  132. and they Clash so if we go and we're just going to uh copy this this is just basically to publish a file to config so we can change those file names so I'm just going to do it in this terminal right here um perfect y UI config and this is

  133. basically just saying um if you if you were to look up here in the views folder we have compon components and then we have a a dropd down. blade. PHP anything in a components folder you can start by typing x- dropdown and that just gives you that whole component but because

  134. um there's a drop down in uh in yui those aliases are the same and then they Clash so we're just going to just we're going to call this Wy for yi- dropdown so if we were to call x- wi- dropdown that's the yui version if we were to just call x- dropdown that's the blade or that's the breeze version and then we should be good to go because we

  135. don't have anything else that kind of conflicts all of these are kind of you know um just ready to go out of the box so if we were to go into our Dash board and if we were to create a new button and let's just say button primary and we're just going to say hi there um it's going to be an x button

  136. and that's again that's a component spec component naming and because we're using yui it's going to give us yui component and if we were to uh go into our dashboard page there we go hi

  137. there perfect now let's make a few changes to color-wise before we color-wise and like theme wise and we're going to add a um a icon to change this up Lille Breeze gives us an easy way of kind of changing that that up so I have a note sharing kind of Icon we're going to change some of the colors so that

  138. anytime we call primary we'll call the rose colors so let's go ahead and do that right now so we can actually all do that in the tail and config so we can call theme I believe it's let's see so if we were to go into yui and we're just going to go into um colors

  139. yeah looks like we can do extend the theme and then colors so theme extend colors and we'll do primary is and looks like we can do colors dot we'll just do uh colors.

  140. rows and there we go so that way if we were to look at our button again these this colors is not defined okay there we go if we're to look at our button again there we go now we have a a button that is ready to go that way we have you know

  141. we can just call our primary color and we have a button with our primary primary so let's go ahead and take a look at um adding that logo Mark that way we have a little bit more stylistic choices out of the box I'm going to grab that color really

  142. quick so I'm going to grab this SVG OMG we're going to grab this and I believe we need to prefer view box to with height and we're just going to copy that let's go

  143. into our logo application logo. blade. PHP just going to copy this in and I'm just going to change a couple things so basically we just need to add this attributes file so this is basically just saying anytime we're we're calling this application logo component we're going to pass in some attributes dynamically and that should be good to

  144. go so if we were to save that and go back into um our uh file there we go we have this right you go and it's it's a little bit bigger than we want um if we were to log out and log in we we have this here um so it looks decent but we can go ahead and make that make that change a little bit so we have the navigation link and

  145. so this is the navigation link for the Live Wire we can see that the application logo is here has an H9 why don't we put this as an H5 and see what that does a little bit small H7 well we'll call it even do an H6 that looks a little better perfect okay now we are ready to start adding our notes actually before

  146. that why don't we why don't we make um our landing page a little better so we log out this is fine but let's just go ahead and um make it so that we uh so that it looks a little bit more like a landing page and so let's just go into that if we were to look into our routes of what's actually being shown here we can see this view slash is going

  147. to the welcome blade. PHP we're going to go into our welcome this is all you know the stuff that we have um so why don't we just like remove everything in the body um actually let's keep this and maybe we'll remove everything below that so if we

  148. were to just grab all this out and okay yeah we have this div and this body okay we're we're good go there and maybe we'll just you know have another div and we'll call this you know P6 MX Auto um max withd

  149. 7xl large pg8 okay so we pie say P6 MX Auto Max with the 7xl large will Max the um the uh not PG padding a little bit more and then we'll go let's just add

  150. our X application logo a class that's a width of uh 24 height of 24 fill current and then text primary then we'll just have a x button of primary we'll call it Excel HF equals

  151. route say log we'll say register so this will be okay if someone just landing on this page um they can get started okay so let's see where this looks like okay decent but we we need we need to Center this and maybe like a uh change some padding up here so we'll say text

  152. Center there we go think we actually need to do items Center Flex oops item Center and then we'll [Music] do um

  153. do a new div here so we can Center it there we go there it is okay so Flex Flex Flex col then CSS is hard okay well we'll add

  154. some space one my of uh four there we go okay that's decent you know it took it took me a little bit while a little bit just to get that going but we have a div we're just centering it and giving some padding and some margin then we have that application logo and our button perfect so if we were to register we have this

  155. Mark ready to go to log in we have this Mark and we have you know the application logo there on the left okay we're ready for note sends or send notes sorry um let's add a button up here where we can access the notes that we're creating so if we were to go into our application um our

  156. navigation we have a live wire layout navigation you can see here we have a dashboard page and then down here is is where um the uh believe the mobile menu is let's see yeah responsive navigation menu here so we're going to add two links one in the regular menu just going to copy this

  157. add it we're going to call this notes route of notes and then active route is notes this is basically just stuff out of the box one thing to note is um it's calling the hre so we're linking it to a named route route of notes and then we're make making this active and that's just a class that we're passing into this x Navin component that's already been

  158. built out for us wire navigate basically just some awesome magic that basically uh allows you to see the page a lot faster because it it it brings up that page on the click instead of the mouse up button so we have notes and we're going to do the same thing down down here so we have responsive Links of dashboard and we're

  159. going to do that for notes that way we can see it in Mobile as well request route is notes so for to go back we actually are going to get an error because route notes is not defined this just gives us some exceptions when we're saying okay hey we named a route of notes in the navigation menu but that actually doesn't exist so let's go ahead and create it so we're to go into web

  160. routes we're just going to say route actually just copy this and change a couple things so route view notes let's just go to a notes file and we'll keep middleware off and we'll name this notes so now we should have that Notes app accessible for to click on we're getting another err there's no view so let's create the

  161. view awesome so we have a a view here for dashboard profile let's go ahead and copy the dashboard just duplicate this and we'll just call this view or sorry notes. blade. PHP and actually since we're going to do a little bit more within notes because we're going to need a notes create notes edit file so why don't we just make this

  162. a little easier and actually let's create a a notes folder so what we can do is in our views we create a new folder notes then we're just going to create a new file of um call this index. blade. PHP so that way we have notes index let's go ahead and copy things in the dashboard just to make it a little bit easier we'll change this to

  163. notes we say hi there notes and our button and our web now instead of just notes we need notes. index and let's change CH the name to um notes index as well so then in our navigation let's go ahead and change that to notes.

  164. index and then up here notes. index perfect so there we go look how Snappy that is it's all server render but because of L of a live wire just makes it easy awesome now we're wanting to grab all the notes and display them

  165. here now we can do that within our our um application so we have our notes index and Lille gives you a bunch of easy ways to kind of do this so we could this is where controllers really come in but since we're doing a little bit of more modern Layel with with volt let's do it the volt way but I'm going to just show the different ways of do it you can do it with a controller where we're kind of saying okay the route view is notes

  166. index and in the index method and a controller we could pass in all the routes of the given user you could also pass it in here where you're saying okay notes index and we could call a function where we uh pass in you know specific um information where we can say okay the notes is the user's

  167. notes we're going to do that for probably another another portion of the application where we can just pass that in in line but here we're just going to use live wire and this is where I think it resonates with with me from someone who who came from you know who kind of came from the JavaScript world I'm like okay I just want to in my file just say say give me all the notes for the loged in user and do

  168. that and and yes it's not necessarily what Lille um might not be like as best of practice especially within older larel older like model view controller that kind of thing but I think it gives you a lot of flexibility especially just getting up and running without having to worry about too much about okay where am I passing this information how am I doing

  169. it so if we were to look at our notes index you could technically even do something like this and there's actually a new helper function within the latest version of PHP to make this e latest version of lerille excuse me so there's an actually a new blade directive and what that means is there's some cool things in Blade where you can just say

  170. this at if F else at o which basically means like okay if there's someone logged in in then we say hey you're logged in then there there's so many different helper functions that larell just provides out of the box and it's all server rendered stuff and they even gives you this um at before you would use at PHP and you

  171. could just write any kind of PHP here so notes equals notes all um and we could say you know like uh models notes all uh where um you know user ID is ID and then we could uh in in here we could

  172. for um each uh notes that's note and then we could you know give let's just say let's let's cut all this out so that way we can just just easier I'm just making this

  173. uh just for an example of this is something that you can do you don't even have to use JavaScript this is just all PHP and this should theoretically work like do we have any notes I think because we we migrated back we don't actually have a note so if we were to go into um we have any nose specific for this users if we were to go into PHP

  174. Artisan Tinker I'm not a tinker expert so I I would just say Okay help uh write a way to create a new note associate with user with ID of one now Tinker is just a way to kind of interact with the database um without having to write manual SQL queries I'm not that smart so basically we could say

  175. okay yeah there we go user equals apps model user find one and then we can say yeah so user equals app models user find

  176. one perfect and then we can say in note equals new have slm models slote and then we have don't note wa I could

  177. do do this I believe

  178. that's okay I should have associated with the user so if we were to go back into it there we go awesome so again that was a lot of finagling just

  179. to show that okay you could do this all within PHP but what if we could do this with a little bit more performance aspect and having to have a little bit more uh interactivity and that's what Livewire provides so let's just go ahead and remove all this and instead of looping through the notes here we're just going to create a new Livewire component and we can do that within the

  180. the terminal we can just say PHP artisan make live wire or sorry we're going to make a volt component um and we're going to call this let's call it we'll say um notes slash

  181. show notes we're going to pass in parameter of D- class this is just saying we want to be this scaffold us out a class based Vault component perfect so you can see here they create a new folder with the show notes that PHP and again what this Live Wire is is basically it's just a separate component but has more interactivity and then we can place it anywhere in our in our

  182. files in our blade view so if I was to say Live Wire notes. show notes let to do this and in here let's just say let's just Echo out and say hi there back here we have hi there it's but this is being rendered in a different place we have this show notes file but in notes index that's where

  183. it's being shown awesome so let's go ahead and just start writing this show notes file and let's just start off with looping through the notes like we were doing before and this is where we're going to get a little bit into you know now uh uh what Live Wire is this is basically

  184. just saying hey we have the ability to connect our PHP our server components our server rendered actions forms everything like that directly to the view without having to do any kind of post requests it's just all Ajax that is magically delivered to us without having to do hardly anything so we're just going to say um one of the things that Livewire kind of gives out of the Ox is

  185. the ability to say public function with now we can return an array here but basically we're just going to return specific information that we can then you know manipulate and view here so if I was to say here and if I was to show title um we'll be able to see oops this title in the page

  186. oh oh there we go there we go uh we'll be able to see this title because now we have this you know this variable this PHP variable of a title that we're passing in to this component and of course so we can modify this and

  187. and be able to pass this back in to the component that's pretty cool huh it has we have live uh hot module reloading out of the box for us okay but what if we need to pass in all of the users um notes we just need to pass everything in and we can do that that's what this

  188. with function that is given to us is allow so we can return and we're going to say return notes and we're going to say that this is oth and this is a helper function that we get we're just saying whoever is logged in that's the O user and we're just going to get their notes um and we're going to order it

  189. by uh send dates that way we kind of are able to see okay which notes are like being sent next we order by sending and then we're going to just get them all and this is just lille's orm it's it's eloquent is what the name of the URL and it is eloquent by the way so you know that makes it a lot easier to to think through but yeah it's just basically an

  190. easy way to interact with our database and I think it's pretty readable um you know grab the specific user who's logged in grab their notes order them by the specific send date of when those answer be ascent and then let's get them all this is where we can pass in that information now because we have all all the notes and all the parameters so if I was to say um you know this is where we can do the for

  191. each Loop so we have for each notes as note and just to kind of um make this a little bit easier we're just going to do uh note title okay so if we to look back into our um if we were to look back into our

  192. table plus and pull this back up uh we can see here that in our notes we have this first hello so if I was to modify this hello world oh and save it perfect awesome everything is ready to go we're displaying this if I was to to modify this and you know paste this in

  193. and of course you know it doesn't it's harder with uids to automatically make it easier but um then we have two and then we'll have another one of um another ID okay we have three now let's just go and make this a little bit

  194. prettier and we'll say oh perfect just a simple of okay we're we have stuff in the database now we're displaying it on the screen this is where we can write a lot of Blade but because we're using yui it's going

  195. to make it a little bit easier to do out of the box so we're just going to say okay for each notes as note let's actually make this you know a div and we do a div here and we'll just say for each notes um first we're going to do a div and we'll just say classes uh flex

  196. and U actually let's make this a little like a card kind of thing um so actually we might have the x- card component available to us so let's see what that looks like and then we have um and Live Wire gives you this wire key initiative which is basically just

  197. saying hey let's make this a little bit it's like passing in a key to a map and react for example and let's just say you this is a div of class Flex justify between and we'll just say for now we'll

  198. just say a that class equals text Tex l f bold hover underline hover text blue 500 and this will be the uh note title

  199. just save this real quick okay perfect actually we need um this so we have X card okay yeah we need a dip here there we go so each card and um we'll space these out a little bit so

  200. class equals space X2 oops space Y2 there we go so we got some cards we got hover links and we got the name of them we to also say we need to we want to pass in okay when is this being sent so div class we'll just say this is extra

  201. small and the cool thing is here we can actually use um Live Wire and looks look at that send date format date month year uh okay we're formatting on a string so what we can actually do here is we can we can parse this with with lel's carbon which is basically like a date function that it provides out of

  202. the box we can just say carbon carbon parse we'll pass in notes send date and then we can format it to month date here okay there we go this is when it's when it's being sent okay so that's

  203. starting to look a little better but let's actually make these look like cards so so we're going to wrap these in a div with a class of grid and we'll say grid uh column is two with a gap of four and we'll just say some some some margin on the top because I think eventually we'll add a space to

  204. be able to create notes here as well so let's wrap that up let's see what that looks like okay it's starting to starting to take place um a little bit better uh let's go ahead and H I think what we should do is we should add uh who these notes are being sent to um as well as you know maybe just some

  205. button to be able to you know um so far we have like editable buttons to be able to click on this and this this would eventually go to where this can be edited but let's have a button to be able to like view the public facing page as well as maybe a button to delete it and of course we haven't created those yet um but what we can do is just kind of set this all up so that when we do create them we're ready to go

  206. so let's go ahead and let's say uh you know down here we have another div like in in this card we have a div of a class of uh Flex items and uh justify between so that way we can have a little bit of space up on top

  207. and um we'll we go ahead and have here be um the uh make it be a little extra small we'll say this is the recipient so and span of class

  208. equals just font semi bold maybe and then we'll go um note recipient and actually we don't need to have a name cuz I think we'll just send the email and it occurs to me that I don't believe we um set up a recipient a recipient um in in the migration so we might have to actually

  209. add that so let's go ahead and check for that um and then we'll go ahead and we don't have a a closing div so we'll go ahead and add that okay that's starting to look a little better and then maybe we'll Al have here we'll have a dip to have a couple buttons so let's just say this is um an x button and this is something that we have within yui we can say that this is a

  210. circle and we'll just say icon of I um and then we'll just have another one that is an icon of trash and let's go ahead and see what that looks like okay so that way we have you know something to to view and then something to delete eventually um again we'll have to close up this div to make these cards look a little better okay that's starting to take take shape I

  211. don't know if I like this white background behind the div so let's go ahead and I believe that actually comes from the note index let's just go ahead and yeah let's just like remove this and let's just see what that looks like okay yeah I think that looks a lot better so now we have this notes where we'll be able to see all the notes that

  212. we've kind of created or our kind of cue to be sent we have some buttons and we're going to wire up all of this so let's go ahead and take a look into creating a new migration because if we take a look at our create notes table we actually don't have a recipient so how in lville do we do we add a a migration

  213. to a previously used table uh well there's a simple way to do that so let's go ahead and open up our terminal so in our terminal uh we basically want to add a new column to a previously existing table and larel we can do that with a a flag to add it to a specific table so we can just say PHP artisan make migration

  214. and we want to add recipient to notes table and usually Within lville the um the best practice I would say is to say okay within um a migration name I want to say the name of the field that I want to add to a table and then what table it represents that way it's just easier to to scan upon scanning okay okay this is

  215. the migration that adds a recipient field to a notes table so we get to look into that um and we can also just do this-- table equals notes that kind of tells us tells it to automatically fill that in for us so if we were to do that take a look at our uh recipient to notes table you can see here that it's automatically associating it to the schema table notes and then here is

  216. where we can just say table string um recipient now we can't exactly run this migration because we already have notes in the database we have notes that exist and we would have to make this nullable so that those wouldn't um you know be have to be uh so we would have to make this nullable so that we wouldn't have any issues within our current notes but what

  217. we're just going to do is we're just going to roll back our previous notes and then create some new notes as well okay and then let's also add a drop column so that if we roll back this migration we know that we're going to remove the recipient from the table so let's go ahead and open up our terminal and we'll just say PHP Artisan migrate roll back to kind of roll back the last

  218. notes uh perfect and then we'll go ahead and migrate again and there we go so now we have the recipient added to the notes tables if we were to pull this up in table plus and take a look at our send notes notes we have this recipient column now so that way we're ready to go so if we are to take a look

  219. back um in our uh show notes Live Wire view we this recipient's already ready to go we're wired up so now instead of having to use PHP Artisan tinker and manually add some notes why don't we just create a live wire view to just do that for us that way we don't have to worry about adding these notes manually and we can just kind of make sure that we were working

  220. with actual real data now of course we can do this with an blade we can kind of add a form here and since actually show notes as a live wire view but if I was in the um note index within blade this isn't anything special this is just HTML server rendered HTML I could add a form and I could do something cool within

  221. laravel where you you have this at csrf or which basically just says hey this is this is a form that's going to push out data it's going to post to a specific specific endpoint but we're in lville so we have the option of making this a lot easier for us so what we're going to do is actually in our show notes I want to say that hey if there are no notes available let's show a create notes uh button to

  222. send us to this create notes page so let's go ahead and wire that up so right here I'm just going to say if um notes is not count but we'll do is is empty so basically if there are no notes that exist within this uh with array and we'll show um a button and basically what this might look like is we'll say uh div class text Center so

  223. that way we it's all all centered we'll say no notes yet click button below we'll just say something like um let's uh create your first note to send perfect um we close out that div then we have to say else so basically if notes is empty showed this then else and we'll actually show a um a button here

  224. as well like create note we'll make this a primary with icon right of plus that just tells us within yui let's make this a little bit prettier using our color that we set up and an icon to the right of this button with a plus and then else show this and then we'll go ahead and say

  225. end um end if so that should be wired up oh here we go we'll go send uh send notes no notes yet okay this this button is not uh this button this button is not in the spot that we would like it in so let's go ahead and do ah okay because that's we did not put this into the text Center and then we'll

  226. just go ahead and say that this has a class of mt6 to separate the note perfect no notes yet let's create your first note to send awesome so obviously this doesn't go anywhere but what we can do is wire this to a specific route so why don't we go ahead and create that route but what we would say is like um we want to send this to and Livewire has that named route so we don't have to go

  227. slash notes slre we can actually just say what route name is this route and we can say notes. create and we're actually going to make this um wire navigate so that's where uh Live Wire 3 gives us that ability to um kind of navigate to a

  228. particular page in a much faster format because it's kind of pulling that info before we even click on the button awesome routes note. create is not defined we knew this um anytime we call a named route the note has to be defined in a web routes folder or file so that's way we'll go ahead and set up let's go ahead to our web routes file and we're just going to let's just go

  229. ahead and copy this and but we want to name this notes SLC create uh notes. create there we go now within LEL one of the ways you could do this is is kind of start to group some of these things you could put them in a controller or we could just kind of start to group them up so that we know hey these are all the notes then we have notes index notes create but since we have a simple

  230. application we're just going to do these individually and it kind of just shows hey it's it's personal preference it's whatever you feel is best whatever is easy to kind of look at and scan a lot of people like to do this where they they look kind of create a common say notes uh routes and that way it's easier to scan on a first pass I just kind of like having them grouped similarly so we

  231. have you know dashboard profile I like to have them separated so I can see them a lot easier um but again personal preference and you'll you'll find that there are so many ways to do it I think that's the beauty of something like lels you have opinions but then you also have places where it's up to you so we have notes. create we need to create this file again like notes index

  232. we have um a blade file that's associated with this view so let's go ahead and create it notes um actually let's just go ahead and duplicate this index so we'll say um create. blade. PHP and since it's in the note folder that's perfect it's exactly what we want we say hey create a

  233. note and we'll say this is create a note perfect now if we're to go back no notes yet create note and there we are looks like everything's ready to go you can see here that it's not active and that's because we mentioned in the um we mentioned in the navigation that this is only going to show that active

  234. CSS if the request route is notes. index and that's fine we we we don't necessarily want you to be thinking you're on the notes page when you're creating a note but there should be an easy way to get back and we we can we can do that later so let's wire up a form and start to create a note so we're going to need a Livewire component and that's since we um don't necessarily

  235. need too much in this blade view what we're just going to do is similar to our our notes index where we're having these notes. show notes let's go ahead and create a new Live Wire component and uh we'll do it similar to how we did the last one so PHP artisan make volt so we'll do notes slash

  236. create note and then we'll do a add of class perfect so if we are to go to our create let's go ahead and add this in Livewire notes. create dnote perfect now we can pull up our create note blade and if we were to just add some text here saying I'm going to create a note everything should be

  237. working perfectly fine same as we expected to we have place the create note and this is being rendered by the Live Wire single file component within volt so let's go ahead and just kind of set up What fields we need to be able to add a note to this um to our to our database So within our class extends we basically have the ability to set up

  238. that state so we can say public uh we have a note subject or note title is what we called it within the database and of course this is just what this is wiring up in the front end so it's not necessarily neat to be specific to what you call in the database but it just makes it a little bit easier as you're kind of working

  239. through these types we'll say no body we have uh note recipient and we have uh note send dat so when we need to actually send this note and then we have one function that we'll probably actually we might have two but we'll have one function for now and we just need to submit the form this is just saying okay when we uh submit a form what happens here and just to kind

  240. of show you what this might look like and we'll just go ahead and die and dump and what we'll just go ahead and do that yeah uh we could do something like grab all all of the data but we'll just do it individually by now and we'll just say something like um a form and let's go ahead we'll add some styling later but what we'll do is here we'll go um X

  241. input and we'll do wire mile note title perfect um let's do a body and we'll do this of X um text area then we'll have a recipient um and we can you know make this an email field later in our validation but just to kind of show you what this looks like within a live wire component since we haven't done any

  242. forms yet we'll do a send date and actually instead of X input type date should be fine um and then we'll just have a button to submit perfect and just to show you what this does on form what we can do and call is basically wire submit equals submit so basically this is calling that public function submit it's calling that

  243. public submit function and and we don't have to worry about doing any kind of okay prevent the default action Live Wire is doing that all for us it's grabbing all of this and since the default for wire model within Live Wire 3 is anytime a form is submitted then uh it it syncs that information so we're

  244. syncing the input to note title when this form is submitted let's take a look at what this looks like if I was to hit of course what we could do is x button so that way it looks a little cleaner awesome there we go we'll make this look a lot nicer in a little bit but we'll say this is my title this is my body that's a

  245. it's a funny phrase um we'll just say uh this is my email and we have a date picker and there we go so we have all of this information just wired up ready for us to go so we can do whatever we want with this and that's the great thing about laravel and Live Wire specifically especially within these single F components it just make it so clean you

  246. know you don't have to um you know grab all the data and you know make sure that you're calling okay anytime this uh you know this is submitted then we need to keep that state it just does it for us this is pretty clean and it's not that many lines of code we we initiate the state we wire it up and then we submit it and we can do whatever we want with this information but let's make this a little cleaner we need to validate this

  247. information before we actually push this into the database and let's just make the the the classes a little bit cleaner as well so what we'll do is we'll just go ahead and say this is a class of space x h space y of four so that way we can kind of separate these a little bit more awesome and then we'll go ahead and say um let's make a placeholder for this

  248. one it's been a great day say note note title there we go yeah note we might call this a subject but it's a title it's a title of what you're what you're sending to the sending to the person and this could be like a label of

  249. um your note there we go and yui gives us all this out of the box which is great and then we'll go ahead and say and recipient is a good word for it but we'll do a placeholder uh of your friend at email.com and then we'll go ahead and say that this is a type of email let's actually add a icon for this

  250. so we'll say icon equals user and then this one may be like icon equals um date I believe actually it might be calendar there we go there we go looks great and then with the button within a form yui has um I actually don't know if it's my fault or not but I I found that we need to kind of put this into its own div so that way we can add some class uh

  251. functionality to the the button itself instead of adding it to the button itself so we can say that this is um we'll say Flex with um we don't actually need the flex so we'll say patting top of four um and then we should be good to go we have a little bit more we'll say that this is a primary button we'll say right icon of I'll say calendar because we're

  252. submitting and and and scheduling this note actually we'll say yeah schedule note and then we'll add a spinner and basically what this spinner does is anytime we call a submit function within a form it's going to automatically give us a spinner so that way we're kind of waiting for the the database to receive that information and then we're just ready to go so we have a scheduled note

  253. button um looks like all this is looking fairly well um maybe we'll just add a little placeholder to this to make it look a little cleaner we'll say um uh share all your thoughts with your friend perfect everything's looking fairly nice so why don't we do the back end and it's

  254. funny because we're just gonna be working in the same file so again similar to like react server components or if you're used to working in something like view instead of having to do all of that Ajax requesting of of or not Ajax but instead of having to kind of hit an API note API call we're just sending this all to the server immediately it's just an ax request that's happening behind the scenes if I

  255. was to um inspect this and look at something like the the network we'll go ahead and clear this uh what we can do is we'll just say test test test test.com and we'll just send something up when we hit this uh and it's probably because we actually aren't sending anywhere just kind of dying dumping but

  256. basically what we'll do is hit a server using Ajax request oh I wasn't recording uh let's go ahead and do that again there we go update we basically hit this update URL and you can see here that it throws a server error because we're dying and dumping but that's basically what it's doing is it's an Ajax request behind the scenes that

  257. Livewire gives us out of the box so let's go ahead and add some validation so we can actually do this in the submit button or Livewire gives us let's actually take a look um so if we were to look at uh live wire. lil.com we need to look at form property LEL actually gives you the ability to create a whole form component which basically has the

  258. ability to add validation out as um as attributes above a specific field so instead of having to do it all within um all within your function we can actually separate this out into its own form method and then be able to validate it separately but because we're doing this Simple app we're not going to do all this we're just going to validate it

  259. within the function itself and that looks like this we can just call validate and this is more Lille than live wire at this point we'll say this validate and we'll say you know no titles required bodies required recipients required send date is required and we can add a little bit more info here as well so if we wanted to say um this is we can add it as an

  260. array it's required it is a um string and then we'll say it is a minimum of let's say five characters we can do the same thing here but we'll say this is a minimum of I always say minimum of like 20 characters perfect for recipient we'll say it's required it is an

  261. email and then we'll go ahead and for the note send date we'll say it's required and it is a date awesome that should be good to go so instead of just dying and dumping what we'll do is we'll go ahead and create a new note so what we can do is we can say off user notes create and then what we'll do is we'll kind of separate all this out

  262. so we'll say um we go ahead and close this up we can say is no title and it's not that because we're creating a title um we'll say this is body of note body recipient of recipient send dat of note send dat and then that should be good to go but what we'll do

  263. is um say published is actually equal to true because we're not saying okay this is published but if they're creating a note we'll say that it's set to publish and that's actually is published and then I think we should be good to go and we don't actually have to to set the user ID because we're calling it from the oth user

  264. so what we can do after this after we submit the form as we can say um let's actually redirect to sln notes or what we could do is the routes note. index again we're using that named route function so if we were to look at our

  265. form um looks like I have a validation error I think I have to do this and this should be the reason why it is

  266. not let's have co-pilot fix this for us that's the issue I was not making an array I was making an object so it is an array okay perfect so we're saying okay auth user notes create and when we create that note give it a title body recipient send date is published as false and then we're redirecting the

  267. note um again there's different ways of doing this we could say something like um you know let's use the note model and say let's create one and then we could pass in you know individually who the user ID is we could do it that way this just makes it a little bit cleaner because we're automatically defaulting to use the user

  268. itself instead of creating no and push excuse me push in the user so we to say the title is test can see here that we start to get some validation and one of the things I I like about yui it gives us that validation out of the box we can also add this x errors down here and that's just a neat little

  269. component that gives us um all all of this inline stuff but also we'll go ahead and refresh this gives us all that inline stuff down here as well so there's four errors with your submission note field must be at least five characters same stuff that you get up here but if you were to have a longer form just makes it a lot cleaner okay so we'll say um my first

  270. note this is my first note and I'm glad to show it and we'll go ahead and say the recipient is Josh Siri gmail.com and we'll go ahead and give a send date of tomorrow there we go okay we have notes in the database and just to show that this is automatically synced with the user if I was to log out and let's go

  271. ahead and register with a new email and let's just say um Josh Smith perfect we still have the hide there dashboard we'll go ahead and change that in a little bit we have notes there's no new notes I can't um now now here's the tricky part okay

  272. there's no notes but if I was to go back and this is where the uuid helps to to to solve this a little bit I was to look at my notes and um we don't have any kind of view but view page just yet so the database is only showing the notes that we have associated with our user now we get into this in a little bit of what a policy is

  273. in the sense of um we don't want anybody to be able to view or edit our notes just because they don't have access to them on a page it doesn't mean they can't find the The UU ID we make it a little a little harder with The UU IDs but you still have access to it technically so let's go ahead and add a create note button to this page here so that way we're not just kind of shooting around in the dark and actually let's

  274. add it to this show notes file so instead of you know for each notes as note we're going to do that but then we're also just going to say that hey let's create a new note as well so else x button and watch should just go ahead and copy what we created up here so we'll just say there we go create no and let's make it look a little cleaner so let's make this look a little

  275. cleaner and we can actually um give some padding to all of these cards so want to say the card is margin top of 12 no let's see might actually looks like we're adding this margin top I don't think it's actually doing anything so let's go

  276. ahead and I'm just add some uh margin bottom to this button there we go perfect so we can create a note go back to our notes page and let's actually add a back button and that's create notes page so let's actually clean this up and just say that this is a Max width that's actually remove this div entirely so that way we're

  277. just showing the create note perfect actually let's say this Max width of like 2 XL there we go looks nice let's go ahead and add um a simple back button here so we'll say x button um back or let's just say all notes and we'll say x button okay that looks good what we'll do is we'll show

  278. an icon on uh left equals left arrow and it might have it might be something else I think it's Arrow left let's actually take a look so in wire ui.com so in wi ui.

  279. deev what we can look at is the buttons and we need the left Arrow so here we go icons okay so it's not icon left it's just icon let's take a look now there we go

  280. so all notes we'll just add some um want some space X4 to this not X that's some space of Y for there there we go we actually just might add some um margin bottom to this of 12 and there we go so back to all notes and of course this doesn't do anything yet

  281. actually add eight and we'll just say it this is href equals route notes. index perfect bam and looks like it doesn't Okay H ref equals there we go so all notes create note all notes

  282. perfect then we're good to go so now let's go ahead and wire it up to be able to view a note so we have the ability to create notes um we can create this note we did the validation and everything like that so let's go ahead and view a note and actually let's show the some of the note text here as well um so if we go to show notes again uh we we kind of

  283. don't have anything to show okay what what is in this note maybe we want a little bit of truncated part of the note that way we can see exactly where this note what is the contents of the note without having to click into it and edit it so let's go ahead and

  284. H let's say for here this is where we are linking to eventually the note to be able to edit it so here before this carbon format date let's go ah and actually add a a string we'll say this is a paragraph and we'll say that this is um we can actually call a PHP function here so string limit note

  285. content I believe we called it body so let's go ahead and take a look there we go okay now our our Flex got messed up a little bit so we'll go ahead and throw this in a div now we have that there we go looks great this is my first note and I'm glad to show it everything looks pretty good so that way we have the ability to click into a note if we had um additional text

  286. here so if I was to Let's actually create a new note we'll say my second note and let's just go ahead create a whole bunch of text on obviously there's better ways to do this but I'm just going to do it this way for now and we'll add it for there there we go and looks like the uh truncated of um 100 is probably not right so let's go

  287. ahead and let's cut it down to 30 there we go that looks better so at least then you know that here's where the the note is going maybe we'll do let's do 50 and make this class equals text x uh extra small and maybe we'll add a little bit of margin on top okay so that way it's a little bit a little bit cleaner okay this is looking pretty good

  288. um actually we might add a a column of of of three just to make it a little bit a little bit cleaner looks nice awesome so we know that the notes that we have when they're being sent who they're being sent to and the ability to or at least buttons to view them and edit them so before we do any viewing why don't we um create the function or the ability to

  289. delete a note so um we should have a new function public function we'll call this delete I'm pass in a note ID so what we're doing is we're saying okay give me the note with this specific note ID and here we can kind of loop since we're already looping through each

  290. note we'll pass in the note ID and obviously this is where we also want to have some security risk because we don't want people deleting notes if they know the ID we want them to only delete notes if they know the ID and it's a note that they have access to so before before we do that we'll just go ahead and say um note equals note where

  291. ID first perfect so this is within Lille we can call it first there's also an option to call Soul um most people just kind of know first off the gate and of course GitHub copal knows it as well I'll just say note delete perfect and again we'll we'll make sure that this is authorized in a

  292. little bit but for now if we were to wire this up we would say the trash is trash button is wire click equals delete this is where we need actually need to have some double quotes because of what we're going to be

  293. passing in delete and then we'll pass in note ID so that should be good to go we are to uh pass this in class Noe not found ah we have not imported it so basically what we need to do is anytime we're trying to access a model like this we can um we have to

  294. import it here so we would go use um appmodel slote so if we were to refresh this again there we go awesome let's create a new one

  295. perfect we're Rock and rolling let's go ahead and take a look at our notes for the otes tall stack so we can cross this off users can type up note and save them we created the models we created the migrations perfect just start on views we started on that we we we took a look at what a view looks like within blade and then Live Wire specifically notes

  296. will be sent publicly via email to view we haven't taken a look into this and the receiver can heart notes that's sent now here's what we should keep in mind that we need to take a look at and I think we can let's actually take a start to take a look at this right now especially when it comes to deleting a note so users can't view other notes notes should be as secure as possible for facing notes and another one that we're going to take a look at is notes

  297. should only be deleted by people who have access because you don't want people um since we're deleting the note by the note ID since this function is publicly available to anyone who has access to this page users could theoretically grab The UU ID in this case um we're we're we're

  298. passing the uuid into a particular note you can see here um if I was to look at table plus The UU ID for this note is this right here of course this is a little bit more secure since we are using a uuid but in Lille Live Wire actually has a fantastic um documentation about this when it comes to uh security basically some steps that you

  299. can take and we're going to take a look at one of those steps right now which is authorizing specific action basically what this means is that only people who can delete notes should be able to delete them so let's go ahead and create that policy now uh we what we can call is just PHP artisan make policy note policy so this is the structure that Lille kind of expects as the name

  300. of the model and then policy and um in this particular case and then we can just call-- model equals note so forget to take out the note policy look um here you can see that uh a bunch of different functions have kind of already been created for us view any view create update delete and it's

  301. already given us the note and the user now basically unless something is filled into this you you you kind of lock everything down so here's what we're going to do we're going to first take a look at the delete option and let's actually just go ahead and say return false so basically no one can delete anything and let's take a look at how this plays

  302. out so if I was to try delete I was able to delete because we haven't authorized this function so let's go ahead and look at how we can authorize that in our um show notes Live Wire so instead of here we're going to find the note and then we're just going to say um let's just go say uh let's just go ahead and say this authorize then we'll say this is the function that we're calling

  303. and the the model that we're passing in so let's check to make sure that this person is authorized to delete the given note since we're finding that note via here okay so let's go ahead and take a look at what this means now that now that we have it authorized let's create a note

  304. and we'll set it for tomorrow schedule note perfect now if has to delete it action is unauthorized so I can't delete this note um but here is where we can actually start to create these policies basically we want to say the user in this case we're automatically passing it in because this it's automatically being passed in Via Livewire via

  305. Lille are they able to delete the given note and we want to say do they own that particular note so here's what we can do user ID is equal to note user ID so that's basically says they're only able to delete this note if the user matches the user ID of the note so if we get authorized now bam we can delete it because we own that particular note but now anyone who has the uid and has an a

  306. login within this application they can't delete these notes perfect we're looking good okay so now we have the ability to delete a note only if that note is assigned or allocated to that specific user so now nobody can just delete any random note if they have The UU ID but now let's get into editing and this is where it's a little bit easier to show just how easy

  307. it is to edit specific specific things if you have access to the given ID in a URL and to do this we're actually going to um take a look at what volt single page routes look like and what this means is what we've been doing recently if we were to take a look at our web route folder we're creating views that link to a specific blade file you know

  308. we have notes create note and show notes sorry that's in Livewire notes create and index and then we're just using specific Live Wire you know functions within our create an index now this is okay but what if you need to just have a whole bunch of different live functionality within a full page now we can do that within Live Wire volt

  309. so let's go ahead and open our terminal and we can actually call PHP artisan make volt notes slash create note and then we'll do D- class oops not create note sorry about that let's do edit note that we should be good perfect okay so we have this volt component let's go

  310. ahead and say hi there this is mostly just to show how we can um oops this is mostly uh just to show how we can I want to close that out now this is mostly just to show how

  311. we can uh create a specific route and point it to a live wire volt component instead of having to create that blade View and it just shows some niceties of Live Wire itself so what we can do is volt route and then we're going to say notes slash notes this is a uh kind of

  312. a wild card function so any ID that we pass in here is going to automatically pull in that particular note so notes where the ID is the ID of the note edit and Lille and Live Wire kind of give us that out of the box we don't have to do anything else notes edit and then we can call the same middleware and name of before and since we don't have a volt pulled in we can just pull that in use

  313. Live Wire Live Wire volt and that should give us everything we need so if we were to go um into our notes and we were to say um let actually create one first and again it's not the best to be able to have to create these all manually

  314. we'll get into um how we can just kind of manually push through notes in a little bit but it's not as timec consuming right now at least for me okay first note is created now what we'll kind of do before we kind of let's go ahead and Link this up to our show notes Live Wire so um we want to view the note right here this this actually let's let's link it right here instead so we

  315. want this to be a route notes. edit and then we're passing in the note let's call wire navigate and let's see what that does first not you can kind of see here that um it's showing the note ID down here so if I to pass in um unable to find component notes. edit and that is because it is

  316. not notes. edit it is note. edit so let's go back note. edit not defined let's see notes. edit okay I think it's because we're not pulling

  317. in h okay so that's where we went wrong let's go ahead and look at our route we have volt route that shows the notes. edit and that's not actually correct because if we were to take a look at our live wire views we have notes edit Das note and so that's what we need to call here notes. edit Das note and so this nameing function isn't isn't necessarily

  318. perfect because we probably should just call this edit but so we have notes create note edit note show notes that's probably redundant because it's in a note folder but since we've done the other ones let's just keep it for now uh but that's where we went wrong so let's go ahead and take a look now and live wi page component layout view not found so this is basically what Livewire single file or single page components um look

  319. like instead of instead of having a full page it needs a layout to adjust to um and what we're going to do is instead of creating a layout we just want to use the app layout that's been already provided and here's what we can do within that edit note and here's what we can do is instead of uh instead of having to create a new layout and kind of copying everything in we just want to use that

  320. app layout and what we can do here is say um first we want to use Livewire SL attributes SL layout and then it's going to throw off some of the the formatting that I have here but we're going to say new um layout layouts. app so if I was to save this there we go perfect so we have notes hi

  321. there there of course we're not pulling in any information but you can see here that this note is you know the the the edit page is working now how do we get the information from that route from this this uh route that we're passing in the note and you can remember if you if you take a look at um our show notes page we're actually just passing in the whole

  322. note function we're not just passing in you know note ID we're actually passing in the entirety of the note and that's a that's a key Point here because where we can use all of the note in our uh because we're passing in a model that's also one keeping it more secure but two we can actually utilize all the functions that and methods that are available within that note so let's take a look at our edit note again and let's

  323. start to scaffold this out so we since we're using the note itself let's just go ahead and call it so or um public function note note and we can use um app SL models slote then let's go ahead and have this Mount function you can see here that uh GitHub copat has kind of already um typing this out for me note

  324. note this note equals note um that's one way of doing it but we also want to uh we also want to fill this note so basically what that means is um everything that because we're going to have Fields since this is an edit we want all of those fields to be automatically filled when the note is

  325. mounted um so we want to say and because we're kind of initializing it here this fill and we'll say note and now if we were to call uh note title we should be able to see that here first note is created

  326. perfectly see so uh this fill basically um just sets the note that the note string or state if you will the note state of this particular Live Wire component we're mounting the note that is being passed in and setting it to

  327. this particular page and then we can say no title we can say no ID um and let's just go ahead and separate and we'll just say class Flex space X2 or space Y2 just to kind of utilize um what all of this is doing and I want mostly just want to kind of show uh what

  328. the when when that authorization piece is going to come in as well uh so we could say you know because all this is is is being passed anything that we have available to the note user email all this can be passed in to this to this page and this is where sensitive

  329. information can technically be leaked Not only would we give people the ability to edit notes but they could see information if we're passing that to the page now the great part about Live Wire being server rendered is we're only passing information to the page that we explicitly pass it's not like we're passing the entirety of the note and then we have access to that um it's not it's not completely true only the information that's being passed into

  330. that note but we do want to make sure that the person who is authorized to edit this note can edit that note so if I was to take this note ID I was to log out and log into that other user I created Josh Smith test.com of course we don't have access

  331. to that note but I was to send notes slash notes slash edit all a sudden I have access to this note that's not a good sign because if we had the ability to edit this note I could do that and of course again the great part about this is we we started off with creating uu IDs and

  332. that's mostly because one it helps just kind of um cut one it helps keep things a little bit more secure and Anonymous but two it's a little bit harder to guess you don't just go around randomly guessing a uu ID but if it was notes SL2 sledit that's a little bit easier

  333. to abuse um but this is where we can again get into laravel's policy so let's go ahead and create that policy well since we already have that policy let's use that note policy and we have create now let's or or sorry edit so that's going to be update and here it is so we basically

  334. want to use the same um uh function that we used for uh the the previous note we can just copy and paste that in return user ID if the note user ID basically this is return true um if the user ID is equal to no user ID return true otherwise return false so if we were to say return false and try to access this

  335. again what we can do of course we're not authorizing this yet but what we can do in the note policy uh I'm sorry in edit note is going to be uh this authorize this is where we can call update for Note so again uh only complete the rest of this if the user and because Livewire kind of

  336. handles all of that for us is actually able to update that note so for to go back this action is unauthorized perfect now if we were to uh return true here then we would able to be able to view this again if we were able if we wanted to return again this is just returning looking for something

  337. that is either true or false and Boolean um we could I don't know return random if you want to have a policy that only allows people at random to access something you could do that I guess but this is where we just want to return true if the user ID is equal to the notes user ID now we should be able to not access this um but if I was to go

  338. back and log out and oh yeah log out and we're logging in with the original user and view the note I'm able to access this again incredibly easy note policies and now we have the ability to edit a note now before we go any further let's go ahead and deploy this to

  339. fly.io so let's go back into our terminal and we basically just want to say uh fly deploy actually before we do that let's go ahead and save this so we we've done a little bit and usually I would like to commit before I do a bunch of bunch of things like this so that's my bad but we'll go ahead and um get add and we'll just say l all and we'll say

  340. that this is um ability or note creation and policies okay and let's go ahead and push that to GitHub now let's run fly deploy so that way we can get everything kind of synced up to our image our our our setup in the clown just so we can verify okay everything is working like we intended to work at least at this moment in time

  341. one of the things that I always like to do is make sure that I push to production as quickly as possible even before we've launched a product or anything like that mostly just to make sure everything still works like I hope hope and intend it to work and that's one of the things that fly actually gives you that makes it super simple is just being able to kind of just push fly deploy and everything should work as expected perfect so let's go ahead and

  342. check out send notes and there we go can't remember if we had actually okay we did create a user so we have no notes but look how speedy this is and again we're on production uh it's insane how fast we can get a lville app running again all

  343. server rendered and we're ready to go perfect so let's go ahead and let's keep trucking along so let's go ahead and take a look at our notes um notes will be sent publicly via email this is one we still have to work on so far everything is looking pretty good we we know that uh users can't view other people's notes we can go ahead and cross that off public one sent and we'll get into that part not should be as secure as

  344. possible we kind of started using U IDs and the benefits behind that and notes should only be deleted by people perfect we're we're we're moving pretty fast so far so let's go ahead and let's just make sure that everything is good to go this is back in test awesome so we have the ability to view a note now let's actually be able to have it be edited so let's go ahead and jump into

  345. our code and this is our edit note so we have the it being authorized it being filled basically we have that information available to us in here and now let's go ahead and uh just make sure this is able to be edited now since we are using the app layout I'll go ahead and look at the um no index just to grab all of this so that way it's kind of a

  346. similar uh similar layout so that way we can say hey we'll edit note and in here um we'll just go ahead and say instead of actually be similar to note create so that way instead of having this Live Wire notes. create

  347. we'll just kind of keep all of this here um so we'll just kind of copy this and paste that in um yeah paste that in here okay so we should just say that hey this is our our our form my

  348. form and let's see what that looks like perfect H looks like we added some extra app layout so we don't actually need this app layout because we're calling that via Live Wire and there we go awesome so notes we're editing note this is where our form is going to go and this is where we're this is where're creating the note viewing the note okay everything's starting to

  349. look good now let's actually build out this form so first let's go ahead and create our state again this is where our note is is living and because we already kind of built that out let's go ahead and just pull it from our create note uh file so create note just pull all of this information so here we have here um and we'll um

  350. puts this in our edit note and maybe we'll we'll also grab the we we won't grab we'll write that from scratch so we'll have a public function of save note because we want this note to be updated and saved and then we'll just go ahead and call um this validate same thing as well note title let's actually grab all of that from the previous create

  351. note just so that we have this in a similar fashion we don't want it to be inv validated any differently then we'll go ahead and say this note update and this is where we can um actually pass in the individual uh strings again so title body recipient and uh is published and I don't think

  352. we're editing the re we we can edit the recipient as well so there we go um and yeah so note title body recipient send dat um and then maybe we'll have an is published as well so that way we can say we'll say we'll say note is published um that way we can just have it be available to say okay hey maybe I created this node but now I don't necessarily know if I want to send it if

  353. I don't want to delete it maybe it's more I don't know just to have that ability and function uh since any note that has been created is automatically set to published uh within our create note file you can see remember here that we created is published um oops is published is equal to true there we go because we want any note that has been created with a send date and that's

  354. required to be published so it's ready to be sent but um we want this to uh be correlate to note is published just in case case I don't know if this needs to be required because it's a Boolean so it it doesn't matter which which uh if you

  355. have it required or not um perfect so let's go ahead and let's actually fill in the rest of the notes so we can say this note title is title body recipient send date note is published and that should be good to go so now let's go ahead and create that

  356. form so let's go ahead and give this a class similar actually we can go ahead and and and take the create note form as well because we're just going to add a couple extra things so let's go ahead and take this and we'll paste this in and I think the only thing that we have to add is a public P button so we'll say x

  357. checkbox and we'll just call this we'll say label equals note published y model equals note is published perfect and let's see what we've got

  358. here awesome and there we go you can see because we didn't add that that default value of publish so if we were to sa save this we'll actually save we'll instead of schedule note we'll just say save note and we'll call this as um save note see how this works so we're uh saving method or action submit does

  359. not exist okay we didn't save this after I said it so so save save note and the form wire submit okay let's go ahead and refresh submit does not exist on component edit note let's see uhuh that is why we don't actually need

  360. wire click we're actually just going to say that this is a type of CIT we can actually change that in our create note as well because any button with a type of submit so we actually don't want this to be a wire click of submit is automatically going to use the forms wire submit function that way we know hey this button is a submit button so let's go ahead and submit what is

  361. associated with the form so now that we have this save it perfect if I was to refresh okay doesn't look like that's saved let's go ahead head and see what's What's Happening Here add a note we have a wire submit save note this note update is published to note

  362. update okay let's go ahead and check our note model to make sure that everything looks good there hm let's just say test save okay so that's changing but not the published let's take a look add a

  363. note filling note and this note publishes note is published and let's double check to make sure that that's what we called it in table plus is published okay now it's showing is set to True Okay the reason why this is not working so uh the reason why no is publish is not working is because we need to set this up as a cast in our model um this took me a little while to

  364. figure out but basically what we we need to do is set up a specific cast so we can say public function casts um oh I'm sorry uh protected casts and then we can set this as an array and mostly we just need is

  365. published and we can set this to Boolean that's mostly just to say that okay this cast is is is set up so that it allows the checkbox to see whether it's actually true or false instead of the 0 to one that we see in the database so now if we were to refresh now it just works so save this and refresh save it refresh okay everything's working

  366. perfectly but we don't really get any feedback this has been refreshed so let's make a few UI changes for that first off let's actually have two buttons one that we can kind of return back to notes so we'll say x button um hre equals route and this is going to be um notes do index perfect um we don't really need

  367. the type button and we'll call this uh we'll say this is this is just the yui attributes that we have we can call this flat and negative and we'll just say back to notes and let's actually call this as a flex and then we can do justify between so we have a little bit of a space between each of these buttons type submit we don't need a right IC ion

  368. of calendar necessarily um but we'll say that uh the spinner is save note so we can actually call the specific to the the wire submit that we're calling and let's see what that looks like actually instead of a instead of having it be primary let's call it secondary it looks a little bit different perfect so we have back to notes and we can see it and okay now how

  369. let's get some uh visualization that this note has actually been saved now when we first installed laravel Breeze we get some components out of the box one of those is a um I believe it is a action yep there we go action message now what this basically does and you can kind of look into this is is it live wire Laro Live

  370. Wire has an ability to emit what is called a event or an action for example we can say after a server function happens say um saving a form we can emit something called like hey this has been saved and basically this action message gives us the ability to do that without having to code this all ourselves this

  371. Bas just basically says when there's a particular event that is returned hey let's show this um saved attribute unless you call a specific slot of what you wanted to be called and then we'll just kind of fade that out after a little bit basically this this just gives us that ability to see a little saved flash after we call um an event so

  372. let's go ahead and add that to our edit note and we'll just go ahead and say this is X action message and we'll just say this is on a note saved again this is the the event that's listening for has a particular uh particular you can see here the prop that it takes is on and we'll just go ahead and call that in our save note we can say um

  373. this oops emit note saved so if we were to go back to our our note and save this oops Adit not found on component H it is not emit it is dispatch because we want to dispatch event so we'll say this dispatch awesome now we should be good to go so if we were to refresh this is

  374. saved now and there we go we get this little saved icon or or attribute to be able to have some visualization of hey this note has now been saved perfect okay we have notes edited we have the ability to create notes um we have the ability to delete notes now before we move further just so we have a little bit more notes to play

  375. with let's look into Cedars now ceders are the ability to basically fill your database with information that can be fake or not fake relatively easy instead of having to manually you know create notes by hand or use that PHP Artisan Tinker function that we kind of did for a little bit this just gives us the ability to automate how notes in this case are notes but anything within a

  376. database is automatically populated so let's go ahead and create a cedar for notes we're going to call a PHP artisan make factory and we're going to say note factory and we're going to have it attached to the model of notes so the factory is what is called when we call a cedar so there's kind of two components a factory which tells a cedar what to actually fill the database with and the cedar which is actually called to

  377. complete complete the task of filling the database and so what we can do here within this definition is we basically can just give larel the ability of saying okay it's kind of GitHub kobat it's kind of creating this for us but basically uh we can set and here's where for user ID um we can actually call user Factory so larvo provides a user Factory

  378. um out of the box for us to be able to create users from scratch um we need to call ID of this Baker uu ID okay now we have um a title of Faker sentence we have a body of paragraph send date of specific date um and we actually want to say this Faker we'll say

  379. date uh let's see date between between oh we'll say date time between and we can say um yeah now plus one year perfect so these should only create notes that are now and in the future we can call like

  380. plus let's just call plus 10 days okay is published Boolean so that's going to be kind of at random actually we we call this to true to automatically set that and then the heart count we haven't actually got into that yet but we'll just say that that's set between uh zero and 20 and that should be good to go so

  381. let's go ahead and let's create a a cedar so again Factory is what is being used as kind of the the code to to run a Cedar and a cedar is going to be the action that takes that factory code and runs it to fill your database

  382. so let's go ahead and create that cedar so it's PHP artisan make Cedar note Cedar there we go awesome note Cedar perfect so let's go ahead and say um when we run this Cedar we want to grab all users so basically all users have been created and for each of them let's just have a

  383. note fact let's pull in the user model um and yeah what go copal kind of created is is fine we basically want to take um the note Factory and let's get let's create 10 and we set the user ID to user ID okay that looks great okay so what do we do now we basically can call this note Cedar and that's going to be

  384. in the Cedar database Cedar section so we can call um this call and instead of user Cedar we'll just call note cedar because we're automatically kind of calling um the note uh the user Cedar class so we'll say a note seedar class perfect and let's go ahead and go back

  385. to our database and we'll just say PHP Artisan DB seed oh looks like we have an error notes. recipient okay we have we did not add in our Factory the ability to have the recipient so we'll say recipient and

  386. this uh equals this Faker email perfect um there we go okay let's go back to our perfect so not Cedar has been run now if we take a look at our our um refresh we have a whole bunch of notes and of course we can probably make style

  387. this and make this a little better but uh for now everything looks like it's good to go we have specific information so this title we can probably no one is probably sending a note with that long of title so so we could either either truncate that or for title we could say instead of sentence we could probably say I believe we can call words um and then we could say you know

  388. five perfect so if we are to um I think I don't know if there's a way to call uh call database or or remove the

  389. latest database entries that were seed and larl let's see if there's a way to do that I actually don't know um so not my great roll back might that might work actually because it says it it calls okay so yeah

  390. PHP migrate okay so we added them again and now we can run PHP arzen DBC perfect now if we were to look at this we should um have our notes okay and five words is a little bit a little bit cleaner and of course we can you know we can style this a little bit better so it's not so

  391. uh so clunky um but it looks like we have things in a decent spot to be able to kind of move forward we have notes that are are easily edited and it looks like this this date didn't work so we have December 13th 14th but it looks like it didn't pull in here and it's probably because it's a it's a date time instead of a date I think in our Cedar we can change

  392. that let's check let's take a look at if that that fixes things um so migrate roll back migrate and DBC perfect let's check now it doesn't have the

  393. correct let's see see if we can fix this um let's see we need a date in a specific format okay so the format is going to be um going do plus 30

  394. days let's see if that does it okay time to run it all again so my go roll back migrate DBC perfect okay so now that we have notes kind of filled in now we can start the process of um what does it look like to

  395. have a publicly view note and then what does it look like to um send notes and this is where we're going to kind of utilize email we're going to utilize KRON jobs and we're going to utilize um background jobs as well to send all these emails every single day if we have 100 users sending thousands of emails background job would be perfect because we don't want all of that to kind of like overload our

  396. server so let's go ahead and create the public view of a note basically when we are showing notes this this little I icon we want to be able to view a note and this is the link that's going to be publicly sent now in our web routes folder we've only used the middleware of O which basically means only people who are logged in can view

  397. any of these pages that we've created so how do we view the information of a note but have that sent so someone doesn't have to be authenticated to view it well let's take a look so we want a route to get and

  398. notes slash note so this is again going to be the the um wild car view of a note and then this is where we could put this into a controller but since we're only using one page let's just build this into the route itself and now a lot of people do you like to use single action controllers so say hey this is the note controller or public note controller for example and it only returns one

  399. method since again since this is a simple application we're just kind of learning the basics of the tall stack we're just going to put all this into the the route itself so we're just going to say a function of we're going to pass in a note and then um we're going to say um hey

  400. if the note is not published we're going to abort with the 404 and we can change this later but if that doesn't pass then we're going to say the user as the note user and we're going to return a view of yeah let's do uh instead of notes show we'll do notes

  401. View and we'll pass in the actual note itself so the note is going to be um the note that is viewed and the user is going to be the particular user uh of the note so since we're grabbing the notes user this is so that we can kind of say okay who sent this note we can publicly display

  402. that and then we'll just go ahead and call this notes and name um notes. viw okay there we go so basically let's bring this in so the note model so if a note is not published we're going to abort a 404 but if that passes let's take the user and pass it into this variable and that's the user of the note so person

  403. who published it has sent it and then we're passing in the actual note itself and the user instead of notes let make this note okay now let's create the notes. viw file so we have notes and let's create view. blade. PHP so this is a public view because we didn't authenticate it there's no middleware on this particular note and since there's no middleware we're going to use the X

  404. guest layout and this is basically um what all the authenticated or all the login and register pages are using the X guest layout can we can see that here layouts guest this is what we'll be using perfect so let's go ahead and H let's just

  405. say div of flex and justify between and we'll go ahead and end that div and just say that this is the um H2 with the class of text okay perfect but instead of notes this is going to be the note

  406. title that's being passed in and then we'll call um the actual nobody but we don't want a string limit anymore because we're we're returning the whole body and then let's say another div andless this this is where the notes

  407. author is going to be and also a um Live Wire component to Heart a heart a note so let's go ahead and say this there's H3 um with the note or actually not note let's the user because we were passing that in name and

  408. this is where we'll have Live Wire heart react we'll pass in the note variable so this is how Live Wire kind of expects any props to be passed in to another Live Wire component is colon note and we can pass in that that note variable that we did for this H3 let's go ahead and say this this is sent from

  409. username let's make that maybe like text small and then in this div let's do a class of flex item Center justify end some space on top perfect and let's see H yeah let's see what this look looks like we don't actually need small

  410. here let's see what this looks like okay so if we were to go here let's take um the the The UU ID here and this is found here so that way we can grab this and let's just remove sledit okay unable to find component okay just so we can see this let's actually create this component but it's

  411. going to be a PHP Artis make volt heart react DCL class okay now there we go perfect so this is our note we have um the note title the note itself and then sent from Josh

  412. Siri okay so everything looks decent with this we maybe add a little bit of space here and and like space on the bottom as well okay that looks that looks decent so if we were to go into uh our heart react let's go ahead and start building this

  413. out so what do we need for heart react basically it's a live wi component where we're just updating the count on the Note function and since we're already we're already we're already passing that in because we took the note that we're passing to the public View and we're passing that model the representative the representation of that note um State

  414. the representation of that note State and we're passing that in to this heart react so let's go ahead and build this out um so let's see we'll just say I think this should actually be relatively simple because we basically uh want to take in the note um we want to say that there's a heart count on this and we could

  415. probably uh keep that consistent so public heart count and we want to um first you know Mount the note so again this is this is taking the the state that is being passed in to this component in this case a note and it's saying okay we want to associate this with an actual model so we're grabbing the um note

  416. heart count there we go and okay so if we are to go back and view this um type of note Anonymous type of note okay let's take a look okay yeah we're not actually bringing in the note here so we'll say

  417. use app slash models slash oops slash note there we go so we don't actually have we're not actually displaying anything here so let's go ahead and let's make a a button we'll say x button we'll make it extra small give it a wire click of and we won't add that yet but that's where we can add the heart count

  418. so increase the heart count we'll say this is a rose button icon of heart and we'll just call a spinner and this is going to only be associated with the method that's associated with this particular component actually anything on the page but since we only have this one live component on the page this just means it's going to show spinner anytime an Ajax request runs on the page and we'll just

  419. say heart count so for take a look perfect 14 now let's go ahead and add some um add some space in between here space X this should work cuz we have the H3 we need some more more space H okay so it doesn't look like it's it's

  420. actually adding that space to it so let's just go ahead and maybe we'll add that um manually to this component um ml4 let's do that okay we'll say it up here so mr4 there we go that looks a little better we'll say MR2 perfect okay so now we have the heart count and we have who

  421. it's sent by we have the note so let's go ahead and wire this up so that where we have the heart count active so we'll say this is public function increase heart count we say this note update heart count okay that looks good so yeah basically all we're doing is is increasing the heart count um every

  422. single time that this button is clicked and again it's taking the note that's being mounted onto this component it's increasing the heart count by that note um and then saving it to the file and there's a couple of different ways to do this so like we could do note this note update or we could do this uh note heart count Plus+ and then we

  423. could do this note save and we could you know make sure that this is is associated with the hard count so that would be one way of doing it or we could definitely keep it what gab copilot sent sent us as well so whatever kind of makes sense in your head I kind of prefer this to know that okay we're increasing it and then we're saving the note um so let's see 15 16 there we go and you could see here

  424. that the Spinners is working if we were to increase the um if we were to throttle this for example let's refresh the page okay now we're throttling so our our our production database is going to

  425. be a lot faster than this but if you have slow us this is just to kind of show that hey something is happening behind the scenes so that way you're not just kind of like waiting okay did this button actually get updated for example and let me make sure I change this back so that way I'm not waiting consistently on this perfect and yeah that that is

  426. looking good so we have a uh a public page now if we are to um go and edit this let's go ah actually and duplicate this page so that way we can go into the edit page and since we're logged in we should be able to edit it let's remove this publish function and refresh and all sudden we

  427. have four four because this that we uh said in our web route if the note was not published abort with 44 perfect we are moving along just great so one thing I do want to show before we get into the backend stuff of jobs and emails is a live wire spinner

  428. and that sounds interesting but basically Live Wire has the ability to create a loading function on a page that is waiting to load specific information now when we have a whole if the user for example has created hundreds of notes of course we could add something like pagination to make it a little bit easier to kind of view all those we could add search functionality I would say dive into that on your own it's

  429. definitely super easy um especially with live wire it gives you that functionality basically for free you don't have to do too much um but if we do have a bunch of notes that we're pulling from a database and we need all that information on one single page that page might take a little bit to load Livewire gives us the ability to basically have placeholder on page until

  430. the page loads so let's take a look so let's go to our show notes this is what live Ral gives us out of the box and I'm going to actually copy and paste this so I'm just going to kind of have this sit here but basically um just because this is a SVG that is a a a spinner I basically found this using um

  431. like Tailwind CSS spinner I think it's Flo by yep here we go so you can just go ahead and kind of copy and paste this particular code from flowy uh but basically it's saying that anytime we're waiting for this component to load then we're just going to show this spinner until that information gets loaded so if we have a whole bunch of different notes that are waiting to get

  432. sent we want to make sure that we show something so that way users can tell hey something is happening on this page and now in our notes index we can add this one little word lazy so anytime we're waiting for notes to load we should see that loading spinner so if I was to go back and take a look at our notes we see this little spinner over here now this is perfect for in

  433. production when we do have more notes to call and it's it does take a little bit more because we're we're grabbing more information than just one page okay now let's dive into actually sending emails so that we can send emails to these recipients so people who created notes um they have a person that they had in mind to send this to but how do we actually send it and this is where Lille gives us some neat functionality out of the box and then we'll hook it up into

  434. production to make it worthwhile so let's dive into our code um and this is where we're going to start with a command now this is mostly just to show that there are different ways of kind of having these server actions we could have um events that says okay anytime a note is created let's schedule a job to send at a certain time but this is what I think is a great way of showing off a

  435. bunch of different features of laravel so let's go ahead and say PHP artisan make Command send scheduled notes Now command is anything that is going to be called by the console so I could if we were to go into our send schedule notes you see here that this is an app send schedule

  436. notes now let's just go ahead and um uh return some text so basically um all I want to do is uh yeah this info hello world okay this is just to show what this is doing if I was to go back into my

  437. terminal and I I was to go PHP Artisan app send schedule notes we get Hello World anything that is inputed into the handle of command gets run when that command is run now we could manually run these commands if we wanted to you could like you know you could set up a GitHub action you could do this manually by sshing into your server there's a bunch of different ways to run these commands but we're going to create this command

  438. so that we can schedule the command to run every single day and not have to worry about it so function handle and we're just going to pull in carbon which is the date so we're going to say now equals um carbon now we're going to say um we want to grab all the notes where note and we

  439. pulled in that model where um is published is equal to true and then we want to say where the um send date is equal to now date uh to date [Music]

  440. string perfect and then we want to get all those notes and then for each um let's actually just go ahead and return the notes so we say note count that way we can kind of show that this is working in the in the in the terminal notes count we'll say this

  441. info um sending this number of schedule notes perfect then we'll do uh for each notes as note oops say send email we don't actually have this created yet this is where

  442. we're going to create a CU a background job that uh can we say we can say okay for every single notes let's send an email to that note let's go ahead and and make that so if we go into our terminal we can say PHP Artis make job send email perfect so now we should be able to see this in our our code so send email dispatch note and

  443. I pulled that in as a job use app jobs send email perfect so now um obviously we don't have anything created in the send email dispatch note but if I was to uh take a look and let's just edit a couple of these to change them to you today and we'll save it and publish it and we'll say this is today published

  444. okay now if we were to go back into our terminal and I was to run PHP Artisan app send scheduled notes we should see that there's at least a couple of notes set for today yep two scheduled notes perfect so now how do we actually send this email again we're creating this command to basically give us the functionality to send these notes send

  445. emails to the recipients of these notes and this is mostly just so we can have um something that is run in the background a Cron job and that's basically a server job that runs on a specific set of time and then we're just ready to ready to send it and now again what this app send schedule notes is doing is just saying

  446. give me all the notes where the send day is equal to day and we might send this at like let's say we'll send it at 9:00 a.m. eastern time so at 9:00 a.m. any note that is scheduled to send for now on our server in terms of hey someone send this for send for December 15th or January 1st or January 18th any note that is set to send on that

  447. particular date is going to be sent on the server over time at 9:00 a.m. eastern okay so let's go ahead and actually create that send email job so if we go to send email this basically just takes in the information in the construct folder and then we're going to handle this as well so we can say public note note and pull this

  448. in perfect and then in the handle we can say the note URL is going to be uh config app URL notes. this note ID and this is basically just saying okay um I want to get the public facing URL of the note so we using the app. URL so in our environment variable um we're saying this is send notes.

  449. test um and so that's going to be the public facing URL of this particular note but when we're in production that's going to obviously be different and we set that in our our fly. Tomo we sent specifically to that sendos stfly dodev and so that's you know that's the information that we have Okay so let's go ahead

  450. and continue sending these emails so we have a note URL um let's say the email content is actually going to be the the subject of the note the title of the note I should say and we'll actually just kind of hardcode this so hello you've received a new

  451. note and then we'll just go ahead and say yeah view it here and then let's go ahead and actually send the email so there's a few way of doing this and we're just going to do it super simple we can actually just say that we just just want to send the email in in a raw format um plain text for example and you can create a fancy like mail I would advise checking out the uh the Lille documentation for

  452. emails so these mailable is basically the ability to create specific views so you can kind of style it with with Tailwind for example it's it's it's pretty fascinating but we're just going to create it in raw format this this time so we're going to say mail and we're going to say raw we're going to take the email content and we're going to um send a message and we're just going to say

  453. message from and this is where um we'll kind of uh hardcode in some data here and of course we can do this with an environment variable but here's where when we push it into production we want to create um we we need this to come from an an email that we have email access to I'm just going to say notes share at zy.

  454. Co and it's from not share actually we'll call it send notes and we'll say this is to this note user email actually it's not it's not the user's email it's going to be the recipient and we'll say the subject is

  455. have a new note from and this is where we can put in um the the users name we add a space there too as well okay this is great this looks good now how do we actually see to make sure this is this is working properly now in the environment we can actually set um mail to log and basically what this is

  456. going to do is this just going to log out information from this from this email so we have a Lille uh log file actually we haven't actually logged anything out probably yet so we can just go ahead and lock and there's a bunch of different options that Lille gives you to kind of view maila bles view emails within your testing environment let's just go ahead and run that setting schedule notes again and

  457. looks like we have an error let's take a look unclosed online 34 for send email H there we go and that should do it so perfect send schedule notes and we have the lay we should have a log file let's take a look um it should be in

  458. public or storage logs leville log and we're going to actually just scroll all the way to the instead of doing that I'll just go ahead and erase it and save and then we'll just run it again okay now we have that raw email basically so it was sending to waters. shaa and Filiberto and then we have hello You' received a new note let's view it here so if I was to take this

  459. link and um access it in the in the browser perfect we have sent from Josh Siri great so it looks like everything is good to go so how do we get these notes this this email these jobs into production well first before we do that we need to make sure that this app SC send schedule notes is actually scheduled to send and that's where we can add it

  460. to uh what's called the console in laravel so if we were to go into console kernel we have the ability to schedule particular commands that we've created and since we have that send schedule notes command we can go ahead and

  461. schedule it so schedule command app send schedule notes and we'll go ahead and say in the time zone of America New York perfect daily at 9:00 a.m. perfect that works great so we're saying okay in New York eastern time every day at 9:00 a.m. let's run this app send scheduled notes and then it's going to do the exactly

  462. same thing that we're doing right now send scheduled notes um if we to take a look at the log in you know we're we're receiving those emails and then I mean we're we're taking all the notes that are set to be scheduled and we're sending them out so actually push us into production um there's a couple things that we need to be aware of when we're pushing to production for ply die IO but the great thing is fly actually makes this super

  463. easy so let's actually take a look at their documentation fly IO larel so for cron and qes it's as simple as scheduling it so we can start the cron Damon enable this in your fly.io same thing for Q's enable this in your cron IO and that's it I mean it's it's as simple as that so if we were to just you know kind copy and paste this and

  464. processes for appon and app worker um in our fly to IO let's go ahead and add this let's put it right here awesome so that's it that's pretty simple so basically fly to IOD now when we are to if we were to deploy this gives us the ability to have a Cron job and schedule all those

  465. commands but we do have to do one more thing we have to set up how we're actually sending emails now there's a bunch of different services that we can use to send an email but I think postmark is one of the easiest to kind of get up and running go ahead and log in now you're going to have to create an account and then create a server basically then you'll have to walk through steps to assign like your DNS records for your domain to uh to postmark to be able to say hey I give

  466. postmark control to send emails from my specific domain so you will have to have a domain handy that you're able to edit some DNS records I've already done that for my domain and what I can do is go ahead and create a new uh server I'll say this is send notes production and this is live so we're going to deliver messages to our recipient and I'm just going to grab an API token and of course I'm going to

  467. delete this so you can't actually view it but we're going to copy this token and this is what we're going to use for our environment variable so if we have to go into our environment and I'm just going to paste this here so that way I just have access to it and again this isn't being saved if you push this to GitHub because get already in Norv files

  468. I'm just going to say uh postmark access token okay perfect just so I have it in place and I'm going to go ahead and actually push all this to GitHub commands notes and public

  469. views perfect okay let's go ahead and open up how to send emails via postmark in larl so in configuration we're going to use the postmark driver so we're going to install this awesome now we can use the postmark token so set the default option in your

  470. applications mail.php configuration file so we want to do that perfect so default is mail mailer or sntp and so that's what we can do in our environment instead of mail mailer and this is what we'll do in our fly.

  471. tumml we'll say mail mailer equals postmark and since to keep it we'll do double quotations just to keep it consistent

  472. awesome okay verify your config servic contains the following options okay let's take a look look so we have postmark token environment postmark token perfect so if we were to look at our environment available instead of postmark access token we'll just call this now how do we input this into fly so that we have a secret now there's a couple ways to do

  473. it so everything is set up and ready to go and of course you have to make sure that within our um our access the settings is is able to send as any email and so if you've already configured this with your domain so I've I have configured it um with my specific sender signature you can see here that I have note share at zy. and I could add

  474. another signature of send notes zy. and we'll create that set from name the send notes app perfect so you could you can look back and where we said the send email we sent it from send notes at s.co I'll just go ahead and say send notes app again this is just to verify

  475. with postmark that you have the ability to send from this email so if you already set that up with your domain and again go through postmark setting settings to kind of go from scratch but you just basically have to set up your dkm and SPF records so that postmark has the ability to send as your domain name okay now I'll set this up in fly.io now fly.io makes it super easy to access any secrets that are available basically you can push it in through the CLI or we can

  476. actually log into the dashboard and create a secret there we just have to make sure that's set to postmark uncore token and a few more things we actually want to do is in our um fly. tml we already have male mailer equals postmark but we'll also do we'll also set mail from

  477. address equals send Notes z.o mail from name equals send notes perfect now instead of putting that environment variable in here because this is not as secure we're just going to access that CLI so we can say fly Secrets

  478. set fly Secrets set postmark token and we'll grab the one that's copied right here so after that's been set we can go ahead and R fly deploy again we can see here that a crown machine and a work worker machine are already getting uh set up and started so that we were ready to go when we actually send that

  479. cron schedule at 9:00 a.m. on Eastern and there we go our app is deployed so let's go ahead and log in and we're going to create a note

  480. there we go our notes ready to be viewed and delete it if we needed to so let's do a couple final touches to make sure that we have everything kind of set up and ready so emails are ready to go out cron jobs are ready to go out we're just going to do two more things we only want to make sure we edit notes before they're actually sent so if the dates passed let's just not have the ability to update this just yet second

  481. we need to make sure that we hook up this view icon and third let's show something fresh on the dashboard okay let's go ahead and go to our show notes so a few things for the I dashboard it's going to be as simple as saying HF equals

  482. route and we'll go notes. View and we'll just pass in the note okay so if we were to go to send notes. test now you should be able to view those notes perfect okay now what about we don't

  483. really need the ability to edit a note if the note date has already been passed if a note has been sent first of all let's utilize our policy that we are creating we only want people to edit these notes if they can update them can edit them now they're probably not going to be able to see or even click on this but this is just to show that liveo has this functionality built in so we can say can

  484. update note and that's as simple as that it's basically just the ability to have that authorization immed imediately in our blade file and we'll say we can show this title else let's actually

  485. show the note title but let's actually make it um TI great 500 and we're not actually going to show any hover underline or anything like that okay so now let's in our can update let's actually modify it so the user can't update it if the notes pass the specific

  486. date because of course there's no really need to so let's look out no policy for update not just going to say return user ID but we also want to make sure that they can update it if the date is imp P pass so we'll say and string actually do send dat is greater than or equal to

  487. now so we refresh this oh and it should not be send dat but as note send dat okay perfect so now you can see 99

  488. authorizing the update of the note there's no even way to click on it of course of course you can modify and that's why we have that authorized authorization available perfect so we have the view we have the ability to click but only if it's in the future or today and even then we don't NE necessarily need today but if you're editing this at like now and then you don't want to send like

  489. if it's not being sent until 9:00 a.m. like I am right now we don't necessarily we can still edit this perfect okay now let's add one more thing to our dashboard and I think we're good to go so let's make one more Live Wire component PHP Hardon make volt we'll

  490. say dashboard stats perfect so let's go ahead and say this is public function with again this is bringing in that information when the component is rendered and we'll return I want to say um notes sent count so we want to know how many notes have

  491. been sent by a particular user so how many notes have been in the past and then how many hearts this user is getting per note so we'll say off user notes and we'll say where we need where send date is less than

  492. now we'll go ahead and say count but actually we'll say where is published is true then we'll grab the count perfect

  493. so notes sent count is the off users notes where Sunday is less than now so notes that have already been sent theoretically we could get more into the Weeds on this for notes that actually been sent we could maybe make a table on the database that says hey note was sent when those emails were actually triggered and we'll just say where is publish is true just to kind of have that extra bit of verication and then

  494. the count and then lastly we'll say um let's say notes loved counts the hearts for each note again that's off user notes some heart count and this is a little neat Layel function that that gives you out of the box it's just basically saying okay for all the notes give me the sum of the heart count integer on all of those

  495. notes and then let just go ahead and add this I'm just going to copy and paste it just for time sake perfect this just a bunch of tail ones show okay hey here's the notes sent here's notes sent count here's notes loved let's go ahead and go to our dashboard and instead of this High there we'll just go ahead and put in that live wire component so live wire and

  496. dashboard stats okay let's take a look bam there we go let's actually edit this so we don't have the white background I like it awesome why don't

  497. we both Commit This to GitHub and push it and then we'll also Run Fly deploy one more time fantastic so we have a full stack application Live ready and production the ability to sign in create new counts to be able to send

  498. notes this is being sent today be able to create them to be able to edit them view them and the ability to delete them if we need to um but all of this has been done within Lille within Live Wire within volt single class components within Tailwind all within the tall stack Tailwind Alpine laravel and live wire and most of this is stuff that larel gives you out of the box like with

  499. larel Breeze with be able to create profiles be able to create users and all this stuff that Lille gives you out of the box so thanks so much for joining with me on this journey to create a full stack application from nothing into production where we kind of took is piece by piece and say okay how do we build an application how do we think about authorization database migrations um how a user is going to interact with their application and overall just how

  500. to build things uh that utilize several different parts of laravel several different parts of a server and make it all one cohesive application I mean we talked about models we talked about migrations we talked about um how to send scheduled jobs and commands and emails and all of this has been done just to be able to show you the power of laravel but also the power of being able to create an application from start to finish it's not as hard as you might

  501. think thanks so much for joining me on this journey let me know if you have any questions uh but this video took a little while to create and I wanted to just make sure that I showed as much about laravel as I could as much about live wire as I could mostly just about this new modern way to build applications within PHP and within lville so it would mean a lot if you commented if you liked if you subscribed and I hope to have more content coming out soon ultimately I love building with the tall stack and hopefully this shows

  502. you just a little glimpse of why I do but also the speed at which you can build full stack applications too

just you here