Courses

[NEW] Vue.js 3 + Laravel 11 + Vite: SPA CRUD

In this lesson, we will create a dropdown select to pick from a list of categories. For this, we will create a new composable and a new API endpoint with the API Resource.

categories select list


Let's start this lesson by creating a Controller with the API route.

php artisan make:controller Api/CategoryController
php artisan make:resource CategoryResource

app/Http/Controllers/Api/CategoryController.php:

use App\Http\Resources\CategoryResource;
 
class CategoryController extends Controller
{
public function index()
{
return CategoryResource::collection(Category::all());
}
}

routes/api.php:

Route::get('posts', [PostController::class, 'index']);
Route::get('categories', [CategoryController::class, 'index']);

In the Resource, we will only add...

This lesson is only for Premium Members.
Want to access all lessons of this course?

You also get:

  • 59 courses (1056 lessons, 44 h 09 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord