-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.php
41 lines (35 loc) · 1.34 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\Auth\LoginRegisterController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/
// Public routes of authtication
Route::controller(LoginRegisterController::class)->group(function() {
Route::post('/register', 'register');
Route::post('/login', 'login');
});
// Public routes of product
Route::controller(ProductController::class)->group(function() {
Route::get('/products', 'index');
Route::get('/products/{id}', 'show');
Route::get('/products/search/{name}', 'search');
});
// Protected routes of product and logout
Route::middleware('auth:sanctum')->group( function () {
Route::post('/logout', [LoginRegisterController::class, 'logout']);
Route::controller(ProductController::class)->group(function() {
Route::post('/products', 'store');
Route::post('/products/{id}', 'update');
Route::delete('/products/{id}', 'destroy');
});
});