api.php 1.2 KB
Newer Older
1
2
3
<?php

use Illuminate\Http\Request;
4
use Illuminate\Support\Facades\Route;
Jacob Priddy's avatar
Jacob Priddy committed
5
use App\Http\Controllers\AuthController;
Jacob Priddy's avatar
Jacob Priddy committed
6
use App\Http\Controllers\UsersController;
7
8
9
10
11
12
13
14
15
16
17

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Jacob Priddy's avatar
Jacob Priddy committed
18
19
Route::post('login', [AuthController::class, 'login']);

Jacob Priddy's avatar
Jacob Priddy committed
20
21
22
23
24
25
26
27
28
29
30
31
32
Route::group(['middleware' => 'auth:api'], static function () {
    Route::group(
        [
            'prefix' => 'users',
        ],
        static function () {
            Route::get('/', [UsersController::class, 'index']);
            Route::post('/', [UsersController::class, 'store']);
            Route::get('{userId}', [UsersController::class, 'get']);
            Route::put('{userId}', [UsersController::class, 'update']);
            Route::delete('{userId}', [UsersController::class, 'delete']);
        }
    );
33

Jacob Priddy's avatar
Jacob Priddy committed
34
35
36
    Route::get('/user', static function (Request $request) {
        return $request->user();
    });
37
});