From the course: Building a Website with Laravel, React.js, and Inertia

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Creating a Post resource

Creating a Post resource

- [Instructor] Let's create our post resource. Remember, we are not building an API now, so we will not need to use the dash dash API flag like we did earlier in the course. In fact, we will just run PHP artisan make model post dash A and press Enter. Laravel created all files that we need plus one that we will not need, the post policy. Again, we won't be using policy in this course as this is beyond the scope of what we are trying to demonstrate here. Let's update the migrations file. Everything we are going to do in this lesson we have already done in the Laravel API lessons, so the best way is to copy everything over as it's going to be exactly the same. (computer keys clicking) Let's add author, title, and body to the post table. Next, let's add the fillable fields to the post model. Create a factor and a seeder to seed our database with some fake posts. (computer keys clicking) Let's run the migration now. (computer keys clicking) And let's see the database. (computer keys…

Contents