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 - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
Creating a Post resource
- [Instructor] Let's create our post resource. To do that, I'll run PHP Artisan Make Model post dash a dash dash API in the terminal. By the way, I've aliased PHP Artisan to Art, so I'll be using art to run artisan commands. It's just a little bit shorter. This dash a flag tells Laravel to create the model factory migration seeder form request, controller, and policy. We won't be needing the policy in this course, but it's easier to delete a file than run multiple commands. So I decided to simply use the dash a flag. This dash dash API flag tells Laravel to create an API resource controller. That does not include the create or edit methods. Let's start with creating the post route in the API dot PHP file. That's all we need to do in here. If you wanted to know what endpoints have been created for us, run PHP Artisan Route List in the terminal. And these are all our endpoints. We are going to update the post migration now. Let's think about it, what is our blog going to need? We will…
Contents
-
-
-
(Locked)
Getting started: Creating a new Laravel project1m 59s
-
(Locked)
Creating a Post resource1m 51s
-
Creating a seeder and a factory1m 15s
-
(Locked)
Creating Post API resource1m 27s
-
(Locked)
Creating PostController index and store methods4m 25s
-
(Locked)
Creating PostController show, update, and destroy methods2m 14s
-
(Locked)
Challenge: Testing API Endpoints with PHPUnit1m 55s
-
(Locked)
Solution: Testing API Endpoints with PHPUnit3m 57s
-
(Locked)
-
-
-