Estado inicial: frontend React + backend Laravel
This commit is contained in:
71
plataforma-tutorias/routes/api.php
Normal file
71
plataforma-tutorias/routes/api.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\CategoryController;
|
||||
use App\Http\Controllers\ContactController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\VideosController;
|
||||
use App\Http\Controllers\WorkshopsController;
|
||||
use App\Http\Middleware\JwtMiddleware;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::post('/register', [AuthController::class, 'register']);
|
||||
Route::post('/login', [AuthController::class, 'login']);
|
||||
Route::post('/refresh', [AuthController::class, 'refresh']);
|
||||
Route::post('/contact', [ContactController::class, 'send']); //proteção da rota no ficheiro index da página de contactos
|
||||
|
||||
Route::middleware([JwtMiddleware::class])->group(function () {
|
||||
/* Rota protegida por middleware JwtMiddleware - Só os utilizadores autenticados podem aceder a esta rota */
|
||||
Route::patch('/profile/{id}', [UserController::class, 'update']);
|
||||
Route::get('/profile/{id}', [UserController::class, 'getUser']);
|
||||
|
||||
Route::get('/videos', [VideosController::class, 'index']);
|
||||
Route::get('/video/{id}', [VideosController::class, 'getVideo']);
|
||||
|
||||
Route::get('/categories', [CategoryController::class, 'index']);
|
||||
|
||||
Route::get('/workshops', [WorkshopsController::class, 'index']);
|
||||
Route::get('/workshop/{id}', [WorkshopsController::class, 'getWorkshop']);
|
||||
|
||||
Route::post('/categories', [CategoryController::class, 'create']);
|
||||
|
||||
Route::post('/inscrever/{id}', [WorkshopsController::class, 'inscrever']);
|
||||
Route::delete('/cancelar-inscricao/{id}', [WorkshopsController::class, 'cancelarInscricao']);
|
||||
|
||||
/* Para fazer a verificação do role_id no frontend das páginas do admin */
|
||||
Route::get('/me', [AuthController::class, 'me']);
|
||||
|
||||
/* Rota protegida por middleware AdminMiddleware - Só os administradores podem aceder as estas rotas */
|
||||
Route::middleware('admin')->group(function () {
|
||||
Route::get('/users', [UserController::class, 'index']);
|
||||
|
||||
Route::post('/create-user', [UserController::class, 'create']);
|
||||
Route::get('/get-user/{id}', [UserController::class, 'getUser']);
|
||||
Route::patch('/edit-user/{id}', [UserController::class, 'update']);
|
||||
Route::delete('/edit-user/{id}', [UserController::class, 'destroy']);
|
||||
|
||||
Route::post('/create-video', [VideosController::class, 'create']);
|
||||
Route::get('/edit-video/{id}', [VideosController::class, 'getVideo']);
|
||||
Route::patch('/edit-video/{id}', [VideosController::class, 'update']);
|
||||
Route::delete('/video/{id}', [VideosController::class, 'destroy']);
|
||||
|
||||
Route::post('/create-workshop', [WorkshopsController::class, 'create']);
|
||||
Route::get('/edit-workshop/{id}', [WorkshopsController::class, 'getWorkshop']);
|
||||
Route::delete('/edit-workshop/{id}', [WorkshopsController::class, 'destroy']);
|
||||
Route::post('/edit-workshop/{id}', [WorkshopsController::class, 'update']);
|
||||
|
||||
/* Depois de protergermos as rotas com middleware, criamos o layout para o admin em pages/privateadmin/_layout.tsx */
|
||||
});
|
||||
|
||||
});
|
||||
18
plataforma-tutorias/routes/channels.php
Normal file
18
plataforma-tutorias/routes/channels.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may register all of the event broadcasting channels that your
|
||||
| application supports. The given channel authorization callbacks are
|
||||
| used to check if an authenticated user can listen to the channel.
|
||||
|
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||
return (int) $user->id === (int) $id;
|
||||
});
|
||||
19
plataforma-tutorias/routes/console.php
Normal file
19
plataforma-tutorias/routes/console.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is where you may define all of your Closure based console
|
||||
| commands. Each Closure is bound to a command instance allowing a
|
||||
| simple approach to interacting with each command's IO methods.
|
||||
|
|
||||
*/
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
18
plataforma-tutorias/routes/web.php
Normal file
18
plataforma-tutorias/routes/web.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider and all of them will
|
||||
| be assigned to the "web" middleware group. Make something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
Reference in New Issue
Block a user