02 - Creating Eloquent API Resource and Finishing CRUD
In this lesson, we will take on two tasks: Implementing Laravel Eloquent API Resource Implementing CRUD operations for the Category model At the end of this lesson, we will have a fully working CRUD for the Category model with transformed API responses: Creating First Resource Let's start by creating our first resource using the artisan command: php artisan make:resource CategoryResource This will create a scaffold for our resource: app/Http/Resources/CategoryResource.php use Illuminate\Http\Request;use Illuminate\Http\Resources\Json\JsonResource; class CategoryResource extends JsonResource{ /** * Transform the resource into an array