Skip to content

Instantly share code, notes, and snippets.

@ualmtorres
Created September 24, 2022 07:35
Show Gist options
  • Save ualmtorres/4dabff3a333d267650c69820edc30e1f to your computer and use it in GitHub Desktop.
Save ualmtorres/4dabff3a333d267650c69820edc30e1f to your computer and use it in GitHub Desktop.
Laravel Product API routes
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ProductController;
/*
|--------------------------------------------------------------------------
| 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!
|
*/
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
Route::group(['prefix'=>'product'], function () {
Route::get('/', [ProductController::class, 'index']);
Route::get('/{id}', [ProductController::class, 'show']);
Route::post('/', [ProductController::class, 'store']);
Route::put('/{id}', [ProductController::class, 'update']);
Route::delete('/{id}', [ProductController::class, 'destroy']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment