title
Laravel From Scratch [Part 5] - Models & Database Migrations

description
In this video we will start to work with models and database migrations. We will use MySQL as our data store. We will be creating a model and database table for our blog posts CODE: Complete Code For This Series https://github.com/bradtraversy/lsapp 10 PROJECT COURSE: Coming Soon..... SUPPORT: We spend massive amounts of time creating these free videos, please donate to show your support: http://www.paypal.me/traversymedia http://www.patreon.com/traversymedia FOLLOW TRAVERSY MEDIA: http://www.facebook.com/traversymedia http://www.twitter.com/traversymedia http://www.linkedin.com/in/bradtraversy

detail
{'title': 'Laravel From Scratch [Part 5] - Models & Database Migrations', 'heatmap': [{'end': 147.726, 'start': 124.602, 'weight': 1}, {'end': 388.852, 'start': 354.506, 'weight': 0.723}, {'end': 893.581, 'start': 867.043, 'weight': 0.914}], 'summary': 'Covers creating a post model and database migration, implementing user authentication, configuring the database, and demonstrating crud functionality for posts in laravel, including model manipulation, route and controller creation, and interaction with the database.', 'chapters': [{'end': 48.339, 'segs': [{'end': 48.339, 'src': 'embed', 'start': 0.546, 'weight': 0, 'content': [{'end': 0.926, 'text': 'Alright, guys.', 'start': 0.546, 'duration': 0.38}, {'end': 3.267, 'text': 'so this is where things are going to start to get interesting,', 'start': 0.926, 'duration': 2.341}, {'end': 8.148, 'text': "because we're going to start to work with the database and we're going to create a model, a post model.", 'start': 3.267, 'duration': 4.881}, {'end': 13.349, 'text': "we're going to create a post database migration and so on.", 'start': 8.148, 'duration': 5.201}, {'end': 17.15, 'text': "So let's go to phpMyAdmin.", 'start': 14.009, 'duration': 3.141}, {'end': 25.152, 'text': "Now if you're using XAMPP, phpMyAdmin is automatically included unless you chose not to install it, but hopefully you did.", 'start': 17.19, 'duration': 7.962}, {'end': 30.033, 'text': "If you aren't using XAMPP and you're using a native LAMP stack, just go ahead and install it.", 'start': 25.872, 'duration': 4.161}, {'end': 34.034, 'text': "It's not that difficult, especially if you're on a Linux distribution.", 'start': 30.053, 'duration': 3.981}, {'end': 36.635, 'text': "So let's go ahead and create a database.", 'start': 34.715, 'duration': 1.92}, {'end': 39.116, 'text': "I'm just going to call this LS App.", 'start': 36.955, 'duration': 2.161}, {'end': 43.017, 'text': "And then that's really all we have to do.", 'start': 41.397, 'duration': 1.62}, {'end': 48.339, 'text': "We're not going to create tables through here or have to do any of that because we have migrations.", 'start': 43.577, 'duration': 4.762}], 'summary': 'Creating a post model and post database migration in phpmyadmin for ls app.', 'duration': 47.793, 'max_score': 0.546, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c546.jpg'}], 'start': 0.546, 'title': 'Creating post model and database', 'summary': 'Covers creating a post model and database migration, including working with phpmyadmin, creating a database named ls app, and the use of migrations for table creation.', 'chapters': [{'end': 48.339, 'start': 0.546, 'title': 'Creating post model and database', 'summary': 'Covers creating a post model and database migration, including working with phpmyadmin, creating a database named ls app, and the use of migrations for table creation.', 'duration': 47.793, 'highlights': ["We're going to start to work with the database and we're going to create a model, a post model.", "We're going to create a post database migration and so on.", "Let's go ahead and create a database. I'm just going to call this LS App.", "If you aren't using XAMPP and you're using a native LAMP stack, just go ahead and install it."]}], 'duration': 47.793, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c546.jpg', 'highlights': ['Creating a post model and database migration.', 'Creating a post database migration.', 'Creating a database named LS App.', 'Installing XAMPP for LAMP stack.']}, {'end': 323.512, 'segs': [{'end': 108.218, 'src': 'embed', 'start': 71.409, 'weight': 2, 'content': [{'end': 76.371, 'text': 'Whoops, what the hell? So PHP artisan.', 'start': 71.409, 'duration': 4.962}, {'end': 80.912, 'text': "And we're going to do make controller.", 'start': 76.391, 'duration': 4.521}, {'end': 83.173, 'text': "And let's say posts.", 'start': 81.973, 'duration': 1.2}, {'end': 92.172, 'text': 'controller all right, so it was created.', 'start': 84.827, 'duration': 7.345}, {'end': 103.239, 'text': "let's look in our app folder, HTTP controllers, and let's refresh, and there it is post controller all right.", 'start': 92.172, 'duration': 11.067}, {'end': 108.218, 'text': 'now we also want to create a model so to do that.', 'start': 103.239, 'duration': 4.979}], 'summary': "Creating a 'posts' controller and refreshing the app folder to find the 'post' controller was successful.", 'duration': 36.809, 'max_score': 71.409, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c71409.jpg'}, {'end': 160.672, 'src': 'heatmap', 'start': 124.602, 'weight': 4, 'content': [{'end': 126.623, 'text': 'so to do that, we just add dash m.', 'start': 124.602, 'duration': 2.021}, {'end': 128.723, 'text': "All right, so let's run that.", 'start': 127.623, 'duration': 1.1}, {'end': 132.028, 'text': "And now you'll see that right here created a post.php.", 'start': 128.884, 'duration': 3.144}, {'end': 132.91, 'text': 'This is our model.', 'start': 132.048, 'duration': 0.862}, {'end': 135.012, 'text': 'And you can see it extends model.', 'start': 133.39, 'duration': 1.622}, {'end': 141.9, 'text': "And if we look in the database folder in migrations, you'll see a create post table.php.", 'start': 135.733, 'duration': 6.167}, {'end': 145.545, 'text': 'Since we added the dash M, it went ahead and created that.', 'start': 142.461, 'duration': 3.084}, {'end': 147.726, 'text': "So let's take a look at this.", 'start': 146.665, 'duration': 1.061}, {'end': 149.747, 'text': 'This is what a migration looks like.', 'start': 148.226, 'duration': 1.521}, {'end': 156.51, 'text': 'So we have a class, a descriptive class, extends migration, and then we have an up and a down function.', 'start': 149.787, 'duration': 6.723}, {'end': 160.672, 'text': "So when we run db migrate, it's going to go ahead and run this.", 'start': 156.75, 'duration': 3.922}], 'summary': 'Adding dash m creates post.php and create post table.php in migrations folder.', 'duration': 36.07, 'max_score': 124.602, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c124602.jpg'}, {'end': 203.3, 'src': 'embed', 'start': 179.122, 'weight': 1, 'content': [{'end': 186.725, 'text': "now you probably want to add more fields, so what we would do is come over here and say table and let's see what we want.", 'start': 179.122, 'duration': 7.603}, {'end': 189.427, 'text': "we want a title right, so let's do table string.", 'start': 186.725, 'duration': 2.702}, {'end': 194.211, 'text': "We're using MySQL, so a string is going to be a varchar.", 'start': 190.848, 'duration': 3.363}, {'end': 197.995, 'text': "So we'll say string, and we want to call it title.", 'start': 195.332, 'duration': 2.663}, {'end': 200.858, 'text': "So that'll actually create a title column.", 'start': 199.016, 'duration': 1.842}, {'end': 203.3, 'text': 'We also want a body.', 'start': 201.999, 'duration': 1.301}], 'summary': 'Adding fields to a mysql table: title as varchar, and body.', 'duration': 24.178, 'max_score': 179.122, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c179122.jpg'}, {'end': 270.469, 'src': 'embed', 'start': 245.833, 'weight': 0, 'content': [{'end': 254.776, 'text': "So users will have an ID, a name, an email that'll have to be unique, a password, and some timestamps, and this Remember Token value.", 'start': 245.833, 'duration': 8.943}, {'end': 258.838, 'text': "It'll also create a password resets table.", 'start': 256.476, 'duration': 2.362}, {'end': 264.627, 'text': "Now there's a few things we need to do before we run the migration and create our tables.", 'start': 260.365, 'duration': 4.262}, {'end': 270.469, 'text': 'We need to first go to the .env file and input our database information.', 'start': 265.147, 'duration': 5.322}], 'summary': 'Creating user database with unique email and password reset table', 'duration': 24.636, 'max_score': 245.833, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c245833.jpg'}, {'end': 323.512, 'src': 'embed', 'start': 296.995, 'weight': 5, 'content': [{'end': 305.502, 'text': "we're going to get an error that says something about maximum length and And to fix that we need to go to.", 'start': 296.995, 'duration': 8.507}, {'end': 309.824, 'text': "And it's possible that you won't have this issue depending on what version you're using.", 'start': 305.502, 'duration': 4.322}, {'end': 311.845, 'text': 'But I kept getting it.', 'start': 310.645, 'duration': 1.2}, {'end': 313.006, 'text': "So I'm going to go to..", 'start': 311.905, 'duration': 1.101}, {'end': 316.068, 'text': 'I forget where..', 'start': 313.006, 'duration': 3.062}, {'end': 317.489, 'text': "No, it's providers.", 'start': 316.068, 'duration': 1.421}, {'end': 320.59, 'text': 'Providers and then app service provider.', 'start': 318.229, 'duration': 2.361}, {'end': 323.512, 'text': 'And what we want to do is bring in something up here.', 'start': 321.251, 'duration': 2.261}], 'summary': 'Fix error related to maximum length in app service provider', 'duration': 26.517, 'max_score': 296.995, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c296995.jpg'}], 'start': 49.339, 'title': 'Laravel model, migration, user authentication, and database configuration', 'summary': 'Demonstrates creating laravel model and migration using php artisan commands, implementing user authentication, adding user id to the post, creating user tables with id, name, email, and password fields, and configuring the database in the .env file, while addressing potential errors related to maximum length when running migrations.', 'chapters': [{'end': 226.082, 'start': 49.339, 'title': 'Creating laravel model and migration', 'summary': 'Demonstrates the process of creating a laravel model and migration using php artisan commands, including creating a controller, model, and migration, and defining fields for the table.', 'duration': 176.743, 'highlights': ["Creating a controller and model using PHP artisan commands The speaker demonstrates using PHP artisan commands to create a controller and model named 'posts', showcasing the practical application of Laravel development.", "Defining fields for the migration including title and body The speaker shows how to define fields for the migration, including creating 'title' and 'body' fields using MySQL data types such as 'string' and 'medium text', illustrating practical implementation of database schema design.", "Explanation of up and down functions in migration file The speaker explains the purpose of the up and down functions in the migration file, detailing how the 'up' function is used to run the migration and the 'down' function is used to roll back the migration, providing technical insight into database migration process."]}, {'end': 323.512, 'start': 226.443, 'title': 'Implementing user authentication and database configuration in laravel', 'summary': 'Covers implementing user authentication in laravel by adding a user id to the post, creating user tables with id, name, email, and password fields, and configuring the database in the .env file. it also addresses potential errors related to maximum length when running migrations.', 'duration': 97.069, 'highlights': ['Creating user tables with ID, name, email, and password fields The chapter discusses creating user tables with fields including ID, name, email, and password.', 'Configuring the database in the .env file It covers configuring the database in the .env file including database name, username, and password.', 'Addressing potential errors related to maximum length when running migrations It addresses potential errors related to maximum length when running migrations and suggests modifying the app service provider to resolve the issue.']}], 'duration': 274.173, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c49339.jpg', 'highlights': ['Creating user tables with ID, name, email, and password fields The chapter discusses creating user tables with fields including ID, name, email, and password.', "Defining fields for the migration including title and body The speaker shows how to define fields for the migration, including creating 'title' and 'body' fields using MySQL data types such as 'string' and 'medium text', illustrating practical implementation of database schema design.", "Creating a controller and model using PHP artisan commands The speaker demonstrates using PHP artisan commands to create a controller and model named 'posts', showcasing the practical application of Laravel development.", 'Configuring the database in the .env file It covers configuring the database in the .env file including database name, username, and password.', "Explanation of up and down functions in migration file The speaker explains the purpose of the up and down functions in the migration file, detailing how the 'up' function is used to run the migration and the 'down' function is used to roll back the migration, providing technical insight into database migration process.", 'Addressing potential errors related to maximum length when running migrations It addresses potential errors related to maximum length when running migrations and suggests modifying the app service provider to resolve the issue.']}, {'end': 782.458, 'segs': [{'end': 354.506, 'src': 'embed', 'start': 323.712, 'weight': 1, 'content': [{'end': 325.053, 'text': 'We want to use illuminate.', 'start': 323.712, 'duration': 1.341}, {'end': 335.079, 'text': 'which is basically just Laravel, slash support, slash facades, slash schema.', 'start': 327.452, 'duration': 7.627}, {'end': 337.581, 'text': 'So we want to bring in this schema library.', 'start': 335.719, 'duration': 1.862}, {'end': 347.73, 'text': "And then in this boot function here, we're just going to say schema, double colon, and then default string length.", 'start': 337.981, 'duration': 9.749}, {'end': 354.506, 'text': "And we're going to set that to 191.", 'start': 351.224, 'duration': 3.282}], 'summary': 'Using illuminate schema library to set default string length to 191', 'duration': 30.794, 'max_score': 323.712, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c323712.jpg'}, {'end': 411.162, 'src': 'heatmap', 'start': 354.506, 'weight': 0, 'content': [{'end': 359.508, 'text': "So if we don't include this here, we're going to get some strange error when we run the migration.", 'start': 354.506, 'duration': 5.002}, {'end': 363.109, 'text': "So let's save that, and then we should be all set.", 'start': 360.628, 'duration': 2.481}, {'end': 366.511, 'text': "So let's open the terminal back up.", 'start': 363.75, 'duration': 2.761}, {'end': 378.076, 'text': "And now what we're going to do is run php artisan migrate.", 'start': 371.653, 'duration': 6.423}, {'end': 383.049, 'text': "and now if we go to our database you'll see that there's a few tables here.", 'start': 379.847, 'duration': 3.202}, {'end': 388.852, 'text': "There's users, there's password resets, those are from the two migrations that Laravel includes.", 'start': 383.089, 'duration': 5.763}, {'end': 396.275, 'text': "Then there's a table called migrations which actually keeps track of our migrations and then the post table which we created.", 'start': 389.392, 'duration': 6.883}, {'end': 401.078, 'text': "So if we click on that and go to structure, you'll see there's an ID primary key.", 'start': 396.355, 'duration': 4.723}, {'end': 402.899, 'text': "it's set to auto increment automatically.", 'start': 401.078, 'duration': 1.821}, {'end': 405.98, 'text': "There's a title, a body and then two timestamps.", 'start': 403.419, 'duration': 2.561}, {'end': 411.162, 'text': "Alright, so our table is created and it's ready to take some data.", 'start': 406.56, 'duration': 4.602}], 'summary': 'Successfully ran migration, database now has tables and is ready to take data.', 'duration': 56.656, 'max_score': 354.506, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c354506.jpg'}, {'end': 460.721, 'src': 'embed', 'start': 430.869, 'weight': 2, 'content': [{'end': 433.59, 'text': "I'm just going to make this bigger and let's clear this out.", 'start': 430.869, 'duration': 2.721}, {'end': 441.272, 'text': 'So to use Tinker, all we have to do is do php artisan tinker.', 'start': 435.17, 'duration': 6.102}, {'end': 444.753, 'text': "And you'll see that we get these brackets right here.", 'start': 441.892, 'duration': 2.861}, {'end': 448.414, 'text': "And that lets us know that we're in the Tinker program.", 'start': 445.173, 'duration': 3.241}, {'end': 456.736, 'text': 'So from here, we can interact with the database with Eloquent, which is an ORM that makes it really easy to do things.', 'start': 449.174, 'duration': 7.562}, {'end': 460.721, 'text': 'So what we can do is we can bring in the model.', 'start': 457.376, 'duration': 3.345}], 'summary': 'Using tinker with php artisan allows interacting with the database using eloquent orm.', 'duration': 29.852, 'max_score': 430.869, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c430869.jpg'}, {'end': 547.474, 'src': 'embed', 'start': 482.101, 'weight': 5, 'content': [{'end': 490.613, 'text': "We're going to say variable post and we'll set that to new and then app and backslash.", 'start': 482.101, 'duration': 8.512}, {'end': 499.922, 'text': "make sure you do a backslash, not a forward slash, and then we can do post just like that and that'll create a new instance.", 'start': 490.613, 'duration': 9.309}, {'end': 504.826, 'text': 'now that instance is basically being held in memory so we can add fields to it.', 'start': 499.922, 'duration': 4.904}, {'end': 510.172, 'text': 'we can say post can use that variable and we can add a title.', 'start': 504.826, 'duration': 5.346}, {'end': 511.433, 'text': "so we'll say post title.", 'start': 510.172, 'duration': 1.261}, {'end': 515.623, 'text': "We'll just call it post one.", 'start': 513.001, 'duration': 2.622}, {'end': 517.124, 'text': 'All right.', 'start': 515.643, 'duration': 1.481}, {'end': 521.907, 'text': 'And then we can press enter and we can add another another field.', 'start': 517.144, 'duration': 4.763}, {'end': 531.794, 'text': "Let's do post body and we'll set that to we'll just say this is the post body enter.", 'start': 521.927, 'duration': 9.867}, {'end': 533.736, 'text': 'So it has a title and a body.', 'start': 532.395, 'duration': 1.341}, {'end': 535.357, 'text': 'Now we can save it if we want.', 'start': 533.896, 'duration': 1.461}, {'end': 538.159, 'text': "So to do that, we'll just do post save.", 'start': 535.417, 'duration': 2.742}, {'end': 540.81, 'text': 'and we get true.', 'start': 540.109, 'duration': 0.701}, {'end': 547.474, 'text': 'So now, if we go back over to, uh, PHP, my admin, and go to our post table,', 'start': 540.93, 'duration': 6.544}], 'summary': "Creating a new instance 'post' with title and body fields, then saving it successfully.", 'duration': 65.373, 'max_score': 482.101, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c482101.jpg'}, {'end': 627.419, 'src': 'embed', 'start': 593.692, 'weight': 3, 'content': [{'end': 594.013, 'text': 'All right.', 'start': 593.692, 'duration': 0.321}, {'end': 596.654, 'text': 'So now we have some data to actually work with.', 'start': 594.693, 'duration': 1.961}, {'end': 606.128, 'text': 'Now, in order to add CRUD functionality for our posts, we need to have a bunch of functions in our controller and we need a bunch of routes.', 'start': 597.782, 'duration': 8.346}, {'end': 608.269, 'text': "Now, let's open up the control.", 'start': 606.288, 'duration': 1.981}, {'end': 610.251, 'text': "I'm just going to get out of the terminal for now.", 'start': 608.309, 'duration': 1.942}, {'end': 612.652, 'text': "We shouldn't need it for a while.", 'start': 611.412, 'duration': 1.24}, {'end': 615.334, 'text': "and let's look at the post controller.", 'start': 613.833, 'duration': 1.501}, {'end': 617.655, 'text': "so we're going to need a lot of different functions here.", 'start': 615.334, 'duration': 2.321}, {'end': 621.256, 'text': "we're going to need an index.", 'start': 617.655, 'duration': 3.601}, {'end': 627.419, 'text': 'okay, so the index is going to be basically the listings of the listing of all the posts.', 'start': 621.256, 'duration': 6.163}], 'summary': 'To add crud functionality, multiple functions and routes are needed in the post controller.', 'duration': 33.727, 'max_score': 593.692, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c593692.jpg'}, {'end': 743.191, 'src': 'embed', 'start': 705.898, 'weight': 4, 'content': [{'end': 711.64, 'text': "All right, so let's do PHP artisan make.", 'start': 705.898, 'duration': 5.742}, {'end': 718.189, 'text': "controller, and then we're going to say dash dash resource.", 'start': 714.625, 'duration': 3.564}, {'end': 729.139, 'text': "But we didn't name it, make controller posts, controller resource.", 'start': 722.513, 'duration': 6.626}, {'end': 737.848, 'text': "And now if we go and look at the controller, let's get rid of this terminal, you'll see that it has all of those functions that I just showed you.", 'start': 729.62, 'duration': 8.228}, {'end': 743.191, 'text': 'Okay, And certain ones have certain parameters.', 'start': 738.949, 'duration': 4.242}], 'summary': 'Creating a php artisan controller with resource functions for posts.', 'duration': 37.293, 'max_score': 705.898, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c705898.jpg'}, {'end': 788.839, 'src': 'embed', 'start': 763.146, 'weight': 8, 'content': [{'end': 770.592, 'text': 'And then edit is going to take an ID for the same reason, because the edit form needs to know which post to show in the form.', 'start': 763.146, 'duration': 7.446}, {'end': 773.638, 'text': 'Update will take in request and ID.', 'start': 771.493, 'duration': 2.145}, {'end': 782.458, 'text': "because we're submitting the form to it and we need to know which one to update and then destroy has an ID so we know which one to update.", 'start': 775.376, 'duration': 7.082}, {'end': 788.839, 'text': "So, if you're, if you're handwriting these and you didn't want to delete your controller and create a new one with resource,", 'start': 783.018, 'duration': 5.821}], 'summary': 'Controller actions take in ids for edit, update, and destroy operations.', 'duration': 25.693, 'max_score': 763.146, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c763146.jpg'}], 'start': 323.712, 'title': 'Laravel, model manipulation, and crud functionality', 'summary': 'Covers using illuminate schema in laravel, setting default string length to 191, running migrations, creating and viewing tables, and using tinker; it also explains model manipulation in php, including creating a new instance, adding fields, and saving records; additionally, it discusses creating crud functionality for posts, including adding functions in the controller, using resource methods, and demonstrating the creation of a controller using php artisan.', 'chapters': [{'end': 456.736, 'start': 323.712, 'title': 'Using illuminate schema in laravel', 'summary': 'Demonstrates using illuminate schema in laravel to set default string length to 191, run migrations, create and view tables, and use tinker to interact with the database using eloquent orm.', 'duration': 133.024, 'highlights': ['Using Illuminate schema to set default string length to 191 In the boot function, the schema library is brought in and the default string length is set to 191, preventing strange errors during migration.', "Running php artisan migrate to create tables Executing 'php artisan migrate' creates tables in the database, including the post table with columns like ID, title, body, and timestamps.", 'Using Tinker to interact with the database using Eloquent ORM The Tinker tool is utilized to insert and select data, leveraging Eloquent ORM for easy database interactions.']}, {'end': 591.811, 'start': 457.376, 'title': 'Model manipulation in php', 'summary': 'Explains how to manipulate a model in php, including creating a new instance, adding fields, and saving records, resulting in the creation of two posts in the database.', 'duration': 134.435, 'highlights': ["Explaining how to save a record in the database The process of saving a record in the database using the 'post save' method is demonstrated, resulting in the creation of two records in the database.", "Demonstrating the creation of a new instance of the model The process of creating a new instance of the model using the 'new' method is explained, resulting in the creation of two instances in memory.", 'Illustrating the addition of fields to the model instance The process of adding fields to the model instance, such as title and body, is demonstrated, resulting in the creation of two posts with titles and bodies.']}, {'end': 782.458, 'start': 593.692, 'title': 'Creating crud functionality for posts', 'summary': 'Discusses the process of adding crud functionality for posts, including creating a bunch of functions in the controller and routes, as well as the use of resource methods. it also demonstrates the creation of a controller using php artisan and the functions required for different operations like index, create, store, show, edit, update, and destroy.', 'duration': 188.766, 'highlights': ['The chapter discusses the process of adding CRUD functionality for posts, including creating a bunch of functions in the controller and routes. It explains the need for various functions such as index, create, store, show, edit, update, and destroy to implement CRUD operations for posts.', 'It also demonstrates the creation of a controller using PHP artisan and the functions required for different operations like index, create, store, show, edit, update, and destroy. The process of creating a controller using PHP artisan and the functions required for different CRUD operations such as index, create, store, show, edit, update, and destroy is explained.', "Update will take in request and ID. because we're submitting the form to it and we need to know which one to update and then destroy has an ID so we know which one to update. The update function requires a request and ID to update the form, while the destroy function needs an ID to know which entry to delete."]}], 'duration': 458.746, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c323712.jpg', 'highlights': ["Running php artisan migrate to create tables Executing 'php artisan migrate' creates tables in the database, including the post table with columns like ID, title, body, and timestamps.", 'Using Illuminate schema to set default string length to 191 In the boot function, the schema library is brought in and the default string length is set to 191, preventing strange errors during migration.', 'Using Tinker to interact with the database using Eloquent ORM The Tinker tool is utilized to insert and select data, leveraging Eloquent ORM for easy database interactions.', 'The chapter discusses the process of adding CRUD functionality for posts, including creating a bunch of functions in the controller and routes. It explains the need for various functions such as index, create, store, show, edit, update, and destroy to implement CRUD operations for posts.', 'It also demonstrates the creation of a controller using PHP artisan and the functions required for different operations like index, create, store, show, edit, update, and destroy. The process of creating a controller using PHP artisan and the functions required for different CRUD operations such as index, create, store, show, edit, update, and destroy is explained.', "Explaining how to save a record in the database The process of saving a record in the database using the 'post save' method is demonstrated, resulting in the creation of two records in the database.", "Demonstrating the creation of a new instance of the model The process of creating a new instance of the model using the 'new' method is explained, resulting in the creation of two instances in memory.", 'Illustrating the addition of fields to the model instance The process of adding fields to the model instance, such as title and body, is demonstrated, resulting in the creation of two posts with titles and bodies.', "Update will take in request and ID. because we're submitting the form to it and we need to know which one to update and then destroy has an ID so we know which one to update. The update function requires a request and ID to update the form, while the destroy function needs an ID to know which entry to delete."]}, {'end': 967.797, 'segs': [{'end': 893.581, 'src': 'heatmap', 'start': 783.018, 'weight': 0, 'content': [{'end': 788.839, 'text': "So, if you're, if you're handwriting these and you didn't want to delete your controller and create a new one with resource,", 'start': 783.018, 'duration': 5.821}, {'end': 792.18, 'text': 'just go ahead and add those functions with those parameters.', 'start': 788.839, 'duration': 3.341}, {'end': 793.161, 'text': 'All right.', 'start': 792.941, 'duration': 0.22}, {'end': 795.401, 'text': "But it's fine if you just delete it and create it again.", 'start': 793.201, 'duration': 2.2}, {'end': 797.122, 'text': 'All right.', 'start': 795.421, 'duration': 1.701}, {'end': 800.042, 'text': 'So now we need routes to all of these.', 'start': 797.242, 'duration': 2.8}, {'end': 809.29, 'text': "So if we go to our routes file, it's going to be kind of a pain in the ass to actually write out every single route.", 'start': 800.162, 'duration': 9.128}, {'end': 818.077, 'text': "so there's actually a shortcut we can take, which is to use route resource, and I don't know if I showed you this before.", 'start': 809.29, 'duration': 8.787}, {'end': 821.999, 'text': 'but if we go back to the terminal, let me clear that out.', 'start': 818.077, 'duration': 3.922}, {'end': 828.744, 'text': "you're not supposed to see that if we clear the terminal we can actually run a command, an artisan command,", 'start': 821.999, 'duration': 6.745}, {'end': 831.446, 'text': 'to show us what routes we have in our application.', 'start': 828.744, 'duration': 2.702}, {'end': 837.891, 'text': 'so we can do that with route, route list and it shows all the routes.', 'start': 831.446, 'duration': 6.445}, {'end': 847.259, 'text': 'so we have slash for the home page, which is a get request, shows us the controller method it goes to about services and even the api user we created,', 'start': 837.891, 'duration': 9.368}, {'end': 850.341, 'text': 'which is just a function or a closure inside the the route.', 'start': 847.259, 'duration': 3.082}, {'end': 853.559, 'text': "Now we'll go back to.", 'start': 851.218, 'duration': 2.341}, {'end': 857.7, 'text': "let's close this up and go back to our routes and we're saying route resource.", 'start': 853.559, 'duration': 4.141}, {'end': 859.721, 'text': 'All right.', 'start': 859.48, 'duration': 0.241}, {'end': 866.943, 'text': 'And then in here, what we want to pass in is posts and we want to map it to a controller.', 'start': 859.861, 'duration': 7.082}, {'end': 875.225, 'text': "So posts controller, and then it's going to actually create all the routes we need for those functions that we created.", 'start': 867.043, 'duration': 8.182}, {'end': 878.006, 'text': "So let's save this and we'll go back to our terminal.", 'start': 875.325, 'duration': 2.681}, {'end': 884.394, 'text': "clear this up and let's again do route list and look at that.", 'start': 879.471, 'duration': 4.923}, {'end': 886.076, 'text': 'it created all that we need.', 'start': 884.394, 'duration': 1.682}, {'end': 889.618, 'text': "so we have, uh, let's see.", 'start': 886.076, 'duration': 3.542}, {'end': 893.581, 'text': 'so post get a get request to post is going to load the index.', 'start': 889.618, 'duration': 3.963}], 'summary': 'Creating routes using route resource and artisan command to list routes.', 'duration': 92.207, 'max_score': 783.018, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c783018.jpg'}, {'end': 967.797, 'src': 'embed', 'start': 945.737, 'weight': 4, 'content': [{'end': 953.384, 'text': "We want to fetch all of our posts in the index function and then pass it to a view that we're going to create to view our posts.", 'start': 945.737, 'duration': 7.647}, {'end': 960.41, 'text': "Alright, and we're going to do the same for create, for edit, and then we'll move on to creating our forms and submitting them to store.", 'start': 954.004, 'duration': 6.406}, {'end': 964.033, 'text': "We'll submit the edit form to update and so on.", 'start': 960.87, 'duration': 3.163}, {'end': 967.797, 'text': 'Alright, so thanks for watching guys and I will see you in the next one.', 'start': 964.534, 'duration': 3.263}], 'summary': 'Developing functions to fetch, create, edit, and submit forms for posts.', 'duration': 22.06, 'max_score': 945.737, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c945737.jpg'}], 'start': 783.018, 'title': 'Laravel routes and controllers', 'summary': 'Covers adding functions to controllers, creating routes using route resource, and using artisan commands to display all routes, as well as creating necessary routes for various http requests and linking them to specific controller functions. it also outlines upcoming tasks of bringing the model into the controller and interacting with it for fetching, creating, editing, and submitting posts.', 'chapters': [{'end': 847.259, 'start': 783.018, 'title': 'Laravel controllers and routes', 'summary': 'Discusses adding functions to controllers, creating routes using route resource, and using artisan command to display all routes in the application, with an example showing the available routes.', 'duration': 64.241, 'highlights': ["The chapter emphasizes the option of adding functions to controllers without deleting the controller and creating a new one with resource, but also mentions that it's acceptable to delete and create again.", 'It introduces the shortcut of using route resource to avoid the tedious process of writing out every single route in the routes file.', "The chapter highlights the use of the artisan command 'route list' to display all the routes in the application, providing a clear example of the available routes including their request types and associated controller methods."]}, {'end': 967.797, 'start': 847.259, 'title': 'Creating routes and mapping to controller', 'summary': 'Explains how to create routes and map them to a controller, resulting in the creation of necessary routes for different http requests such as get, post, put, patch, and delete, linking to specific controller functions. it also outlines the upcoming tasks of bringing the model into the controller to interact with it and fetching, creating, editing, and submitting posts.', 'duration': 120.538, 'highlights': ['Routes are created and mapped to a controller, resulting in the creation of necessary routes for different HTTP requests such as get, post, put, patch, and delete, linked to specific controller functions. The chapter explains the process of creating routes and mapping them to a controller, which results in the generation of all required routes for various HTTP requests, effectively linking them to specific controller functions.', 'Upcoming tasks include bringing the model into the controller to interact with it and performing actions such as fetching all posts in the index function and passing them to a view, as well as creating, editing, and submitting posts. The upcoming tasks involve bringing the model into the controller to interact with it, fetching all posts in the index function, passing them to a view, and handling actions such as creating, editing, and submitting posts.']}], 'duration': 184.779, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/neSHAWdE44c/pics/neSHAWdE44c783018.jpg', 'highlights': ['The chapter emphasizes adding functions to controllers without deleting the controller and creating a new one with resource.', 'Introduces the shortcut of using route resource to avoid the tedious process of writing out every single route in the routes file.', "The chapter highlights the use of the artisan command 'route list' to display all the routes in the application.", 'Routes are created and mapped to a controller, resulting in the creation of necessary routes for different HTTP requests linked to specific controller functions.', 'Upcoming tasks involve bringing the model into the controller to interact with it, fetching all posts in the index function, passing them to a view, and handling actions such as creating, editing, and submitting posts.']}], 'highlights': ['Creating a post model and database migration.', 'Creating a post database migration.', 'Running php artisan migrate to create tables.', 'Using Illuminate schema to set default string length to 191.', 'Using Tinker to interact with the database using Eloquent ORM.', 'The chapter discusses the process of adding CRUD functionality for posts, including creating a bunch of functions in the controller and routes.', 'The chapter emphasizes adding functions to controllers without deleting the controller and creating a new one with resource.', 'Introduces the shortcut of using route resource to avoid the tedious process of writing out every single route in the routes file.', "The chapter highlights the use of the artisan command 'route list' to display all the routes in the application.", 'Routes are created and mapped to a controller, resulting in the creation of necessary routes for different HTTP requests linked to specific controller functions.']}