diff --git a/app/Http/Controllers/WorkstationsJobsController.php b/app/Http/Controllers/WorkstationsJobsController.php index 77620a59..0f7481da 100644 --- a/app/Http/Controllers/WorkstationsJobsController.php +++ b/app/Http/Controllers/WorkstationsJobsController.php @@ -15,36 +15,6 @@ class WorkstationsJobsController extends Controller { - public function index() - { - return view('workstations.start'); - } - - public function controlEquipment() - { - // A partir deste dado consigo receber os valores do WS,TE e Equipment - $controlEquipmentWorkstationId = 33; - - $receiveEquipment = Equipment::where('equipment_id', 1443)->first(); - - $task_todo = 1; - return view('workstations.workstations', [ - 'task_todo' => $task_todo, - 'controlEquipmentWorkstationId' => $controlEquipmentWorkstationId, - 'receiveEquipment' => $receiveEquipment - ]); - } - - // public function receiveAnswersEquipment(Request $request) - // { - // $receiveAnswersElementalTasks = new workstationsTaskAnswers; - - // $receiveAnswersElementalTasks->control_equipment_workstation_id = $request->control_equipment_workstation_id; - // $receiveAnswersElementalTasks->answer_json = - - // } - - // Recebe as perguntas e respostas e deve criar um linha nova. public function receiveAnswersEquipment(Request $request) { // Primeiro ele deve criar a associação entre id atual do control + perguntas e respostas diff --git a/app/Http/Middleware/CheckUserType.php b/app/Http/Middleware/CheckUserType.php index 9ae11331..be7de576 100755 --- a/app/Http/Middleware/CheckUserType.php +++ b/app/Http/Middleware/CheckUserType.php @@ -15,17 +15,17 @@ class CheckUserType * * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ - public function handle(Request $request, Closure $next) - { - if (auth()->user()) { - $currentRoute = Route::currentRouteName(); - $userType = auth()->user()->userType->type_user; - if ($userType == 'Super_Administrador' && $currentRoute != 'home') { - return redirect()->route('home'); - } elseif ($userType == 'Técnico' && $currentRoute != 'enterWorkstation') { - return redirect()->route('enterWorkstation'); - } + public function handle(Request $request, Closure $next, $routeType) + { + $userType = auth()->user()->userType->type_user; + + if ($routeType == 'enterWorkstation' && $userType != 'Técnico') { + return redirect()->route('home'); // ou qualquer rota padrão para redirecionar + } + + if ($routeType == 'home' && $userType != 'Super_Administrador') { + return redirect()->route('enterWorkstation'); // ou qualquer rota padrão para redirecionar } return $next($request); diff --git a/routes/web.php b/routes/web.php index 658e48d5..8e93bfa1 100755 --- a/routes/web.php +++ b/routes/web.php @@ -30,40 +30,16 @@ use App\Http\Controllers\WorkstationsJobsController; - +// Esta rota so pode aceder quem tiver o link atravez do email Route::get('formulario', function () { return view('email/FormAdmin'); })->name('formulario'); -route::get('testt', function () { - return view('test'); -}); - -Route::get('te102', function () { - return view('workstations.TE10(2)'); -}); - -Route::get('user-data', [PreparedProjectController::class, 'getData1'])->name('getData'); -Route::get('preparedProject/{ProjectId}', [PreparedProjectController::class, 'PreparedProject'])->name('preparedProject'); -Route::get('EditProjectForArticulated', [PreparedProjectController::class, 'editProjectForArticulated'])->name('EditProjectForArticulated'); - -Route::get('ExecutionProject/{ProjectId}', [ExecutionProjectController::class, 'receiveExecutionProject'])->name('ExecutionProject'); -Route::get('/ReceiveEquipmentIdForShowModal/{EquipmentID}', [ExecutionProjectController::class, 'receiveEquipmentIdForShowModal'])->name('ReceiveEquipmentIdForShowModal '); - - // Email Route::get('/your-verification-route/{id}/{hash}', [UserController::class, 'yourVerificationMethod']) ->middleware(['auth', 'signed', 'throttle:6,1']) ->name('verification.verify'); -Route::get('/receiveThisShit', function () { - return redirect()->route('test'); -})->name('verification.notice'); - -Route::get('/testExcel', function () { - return view('createProjectExcel'); -})->name('testExcel'); - /* |-------------------------------------------------------------------------- @@ -76,191 +52,128 @@ | */ -/* -|-------------------------------------------------------------------------- -| User_Type (Super_Administrador) -|-------------------------------------------------------------------------- -|*** Routes unique access to the Super_Administrator, due to its sensitive data. -| -| -*/ -// Route::middleware(['auth', 'verified', 'checksuperadmin', 'checkAdmin'])->group(function () { -// Profile page -Route::get('usersProfiles/{id}', [userController::class, 'UserProfile'])->name('usersProfiles'); +// Rotas protegidas que exigem verificação de e-mail +Route::middleware(['auth'])->group(function () { - -Route::post('enviar-formulario', [FormController::class, 'enviarEmail'])->name('enviar.formulario'); -/* + /* |-------------------------------------------------------------------------- - | CRUD - users + | User_Type (tecnico) |-------------------------------------------------------------------------- - | - | Definition routes to implement the CRUD model - | + |*** Routes unique access to the technical */ -/* + Route::middleware(['checkUserType:enterWorkstation'])->group(function () { + + Route::get('enterWorkstation', function () { + return view('workstations.start'); + })->name('enterWorkstation'); + + Route::get('/getEquipmentData/{equipment_id}', [WorkstationsJobsController::class, 'getEquipmentData'])->name('getEquipmentData'); + Route::post('receiveAnswersEquipment', [WorkstationsJobsController::class, 'receiveAnswersEquipment'])->name('receiveAnswersEquipment'); + }); + + /* + |-------------------------------------------------------------------------- + | User_Type (Super_Administrador) + |-------------------------------------------------------------------------- + |*** Routes unique access to the Super_Administrator, Administrator + */ + Route::middleware(['checkUserType:home'])->group(function () { + Route::get('/', [ProjectoDatacontroller::class, ('HomePage')])->name('home'); + + /* |-------------------------------------------------------------------------- - | Create Users with Super Admin, Admin + | CRUD - users |-------------------------------------------------------------------------- - | - |The creation of records can be done by both the admin and the superAdmin, - |however the Admin will not have access to the data of the SupersAdmins only. - | + | Definition routes to implement the CRUD model */ + Route::controller(userController::class) + ->group(function () { -Route::controller(userController::class) - ->group(function () { + Route::get('users/listUsers', 'listUsers')->name('users.list'); + Route::get('users/listCompanies', 'listCompanies')->name('users.company'); + Route::get('users/{id}', 'show')->name('users.Show'); + Route::get('users/{id}/edit', 'edit')->name('users.edit'); + Route::put('users/{user}', 'update')->name('users.update'); + Route::delete('users/{user}', 'destroy')->name('users.destroy'); + Route::post('editProfile/{id}', 'EditProfile')->name('editProfile'); + }); - Route::get('users/listUsers', 'listUsers')->name('users.list'); - Route::get('users/listCompanies', 'listCompanies')->name('users.company'); - Route::get('users/{id}', 'show')->name('users.Show'); - Route::get('users/{id}/edit', 'edit')->name('users.edit'); - Route::put('users/{user}', 'update')->name('users.update'); - Route::delete('users/{user}', 'destroy')->name('users.destroy'); - Route::post('editProfile/{id}', 'EditProfile')->name('editProfile'); + /* + |-------------------------------------------------------------------------- + | Management of projects created + |-------------------------------------------------------------------------- + | + */ + Route::controller(CreateProjectController::class) + ->group(function () { + + // indication of progress bar to projects that are in 'Planning' + Route::get('test1/{id}', 'showStep1')->name('test1'); + Route::get('test2/{id}', 'showStep2')->name('test2'); + Route::get('test3/{id}', 'showStep3')->name('test3'); + + // Para adicionar uma tarefa Complementar + Route::post('addFurtherTasks', 'addFurtherTasks')->name('addFurtherTasks'); + Route::post('deleteFurtherTasks', 'deleteFurtherTasks')->name('deleteFurtherTasks'); + + Route::get('createProject', 'createProjectForStep1')->name('createProject'); + + Route::post('receiveEquipmentToAssociateTasks', 'receiveEquipmentToAssociateTasks')->name('receiveEquipmentToAssociateTasks'); + Route::get('finishCreatingProject/{numberProject}', 'finishCreatingProject')->name('finishCreatingProject'); + Route::get('testDataTables', 'testDataTables')->name('testDataTables'); + Route::get('workstationsAssociationTasks', 'workstationsAssociationTasks')->name('workstationsAssociationTasks'); + Route::get('AddNomenclatureWorkstation', 'AddNomenclatureWorkstation')->name('AddNomenclatureWorkstation'); + Route::get('removeProjectEquipment', 'removeProjectEquipment')->name('removeProjectEquipment'); + Route::delete('deleteWorkstation/{name}', 'deleteWorkstation')->name('deleteWorkstation'); + Route::post('EditEquipmentsProjects', 'EditEquipmentsProjects')->name('EditEquipmentsProjects'); + Route::post('newProject1', 'processStep1')->name('processStep1'); + Route::post('createWorkStations', 'createWorkStations')->name('createWorkStations'); + + Route::post('test1', 'EditprocessStep1')->name('EditprocessStep1'); + Route::post('test2', 'processStep2')->name('processStep2'); + Route::post('test2CreateEquipment', 'createEquipmentManual')->name('test2CreateEquipment'); + Route::post('test3', 'processStep3'); + Route::delete('removeEquipment/{id}', 'removePendingEquipment')->name('removeEquipment'); + Route::post('CreateNewEquipmentFromPendingEquipment/{id}', 'CreateNewEquipmentFromPendingEquipment')->name('CreateNewEquipmentFromPendingEquipment'); + Route::post('create-equipament-project', 'createEquipamentProject')->name('createEquipamentProject'); + Route::get('equipments/{id}/attributes', 'getAttributes'); + + /* + |-------------------------------------------------------------------------- + | Template Excel + |-------------------------------------------------------------------------- + */ + Route::get('template1/{numberProject}', 'receiveUnitsForExcelTemplate')->name('download'); + }); + + Route::get('user-data', [PreparedProjectController::class, 'getData1'])->name('getData'); + Route::get('preparedProject/{ProjectId}', [PreparedProjectController::class, 'PreparedProject'])->name('preparedProject'); + Route::get('EditProjectForArticulated', [PreparedProjectController::class, 'editProjectForArticulated'])->name('EditProjectForArticulated'); + + Route::get('ExecutionProject/{ProjectId}', [ExecutionProjectController::class, 'receiveExecutionProject'])->name('ExecutionProject'); + Route::get('/ReceiveEquipmentIdForShowModal/{EquipmentID}', [ExecutionProjectController::class, 'receiveEquipmentIdForShowModal'])->name('ReceiveEquipmentIdForShowModal '); + + + //Gerir os Ativos gerais + Route::get('manageAssets', [ProjectoDatacontroller::class, 'ManageAssets'])->name('manageAssets'); + Route::get('units/{id}', [ProjectoDatacontroller::class, 'showUnit'])->name('showUnit'); + + + Route::get('usersProfiles/{id}', [userController::class, 'UserProfile'])->name('usersProfiles'); + Route::post('enviar-formulario', [FormController::class, 'enviarEmail'])->name('enviar.formulario'); + + Route::get('/CreateUsers/{id}', [Pending_UserController::class, 'ShowFormUser'])->name('ShowPendingUser'); + Route::post('formulario/receive', [Pending_UserController::class, 'store'])->name('criarUser'); + Route::get('/CreateUsers', [Pending_UserController::class, 'ListPendingUsers'])->name('CreateUsers'); + Route::post('/register', [CustomRegistrationController::class, 'store'])->name('register'); + + // Mostrar Instalação click + + // Route::middleware(['checkUserType:enterWorkstation']) }); - -Route::controller(CreateProjectController::class) - ->group(function () { - // indication of progress bar to projects that are in 'Planning' - Route::get('test1/{id}', 'showStep1')->name('test1'); - Route::get('test2/{id}', 'showStep2')->name('test2'); - Route::get('test3/{id}', 'showStep3')->name('test3'); - - // Para adicionar uma tarefa Complementar - Route::post('addFurtherTasks', 'addFurtherTasks')->name('addFurtherTasks'); - Route::post('deleteFurtherTasks', 'deleteFurtherTasks')->name('deleteFurtherTasks'); - - Route::get('createProject', 'createProjectForStep1')->name('createProject'); - - - Route::post('receiveEquipmentToAssociateTasks', 'receiveEquipmentToAssociateTasks')->name('receiveEquipmentToAssociateTasks'); - Route::get('finishCreatingProject/{numberProject}', 'finishCreatingProject')->name('finishCreatingProject'); - Route::get('testDataTables', 'testDataTables')->name('testDataTables'); - Route::get('workstationsAssociationTasks', 'workstationsAssociationTasks')->name('workstationsAssociationTasks'); - Route::get('AddNomenclatureWorkstation', 'AddNomenclatureWorkstation')->name('AddNomenclatureWorkstation'); - Route::get('removeProjectEquipment', 'removeProjectEquipment')->name('removeProjectEquipment'); - Route::delete('deleteWorkstation/{name}', 'deleteWorkstation')->name('deleteWorkstation'); - Route::post('EditEquipmentsProjects', 'EditEquipmentsProjects')->name('EditEquipmentsProjects'); - Route::post('newProject1', 'processStep1')->name('processStep1'); - Route::post('createWorkStations', 'createWorkStations')->name('createWorkStations'); - - Route::post('test1', 'EditprocessStep1')->name('EditprocessStep1'); - Route::post('test2', 'processStep2')->name('processStep2'); - Route::post('test2CreateEquipment', 'createEquipmentManual')->name('test2CreateEquipment'); - Route::post('test3', 'processStep3'); - Route::delete('removeEquipment/{id}', 'removePendingEquipment')->name('removeEquipment'); - Route::post('CreateNewEquipmentFromPendingEquipment/{id}', 'CreateNewEquipmentFromPendingEquipment')->name('CreateNewEquipmentFromPendingEquipment'); - Route::get('template1/{numberProject}', 'receiveUnitsForExcelTemplate')->name('download'); - Route::post('create-equipament-project', 'createEquipamentProject')->name('createEquipamentProject'); - Route::get('equipments/{id}/attributes', 'getAttributes'); - }); - - - - -/* -|-------------------------------------------------------------------------- -| Create Users with Super Admin -|-------------------------------------------------------------------------- -| -| 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('manageAssets', [ProjectoDatacontroller::class, 'ManageAssets'])->name('manageAssets'); - - -Route::get('enterWorkstation', [WorkstationsJobsController::class, 'index'])->name('enterWorkstation'); -Route::get('controlEquipment', [WorkstationsJobsController::class, 'controlEquipment'])->name('controlEquipment'); - -Route::get('/getEquipmentData/{equipment_id}', [WorkstationsJobsController::class, 'getEquipmentData'])->name('getEquipmentData'); - - -Route::post('receiveAnswersEquipment', [WorkstationsJobsController::class, 'receiveAnswersEquipment'])->name('receiveAnswersEquipment'); - - -Route::middleware(['auth', 'checkUserType'])->group(function () { - - // Rotas protegidas que exigem verificação de e-mail - - Route::get('/', [ProjectoDatacontroller::class, ('HomePage')])->name('home'); }); - -/* -|-------------------------------------------------------------------------- -| CRUD -Instalation -|-------------------------------------------------------------------------- -| -| 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! -| -*/ - -// Mostrar Instalação click -Route::get('units/{id}', [ProjectoDatacontroller::class, 'showUnit'])->name('showUnit'); - - -/* - |-------------------------------------------------------------------------- - | Create Projects with Super Admin and Admin - |-------------------------------------------------------------------------- - | - |Crud model for the application's projects, where both their creation and the indication of project statuses are handled. - | - */ -Route::get('/CreateUsers/{id}', [Pending_UserController::class, 'ShowFormUser'])->name('ShowPendingUser'); -Route::post('formulario/receive', [Pending_UserController::class, 'store'])->name('criarUser'); - - -Route::post('/register', [CustomRegistrationController::class, 'store'])->name('register'); - -Route::get('/CreateUsers', [Pending_UserController::class, 'ListPendingUsers'])->name('CreateUsers'); - - - -/* -|-------------------------------------------------------------------------- -| Template Excel -|-------------------------------------------------------------------------- -| -| 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! -| -*/ - - - -/* -|-------------------------------------------------------------------------- -| Create Project -|-------------------------------------------------------------------------- -| -| 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! -| -*/ - - -/* -|-------------------------------------------------------------------------- -| CRUD -Equipaments -|-------------------------------------------------------------------------- -| -| 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! -| -*/ - - // *** All api routes have been moved to api.php *** - Route::get('/api/receiveEquipmentsExecutionProject/{receiveNumberProject}', [ExecutionProjectController::class, 'receiveEquipmentsExecutionProject'])->name('receiveEquipmentsExecutionProject'); Route::get('/api/receiveAllEquipments', [ProjectoDatacontroller::class, 'receiveAllEquipments']); Route::get('/api/receiveEquipmentsProject/{receiveNumberProject}', [ProjectoDatacontroller::class, 'receiveEquipmentsProject']); @@ -271,34 +184,4 @@ Route::get('/api/ambits/prepared{equipmentType}', [PreparedProjectController::class, 'getAmbits']); Route::get('/api/equipment/{id}', [CreateProjectController::class, 'showJson']); Route::get('/api/installations/', [CreateProjectController::class, 'getByUserNif']); -Route::get('/api/ambits/{equipmentType}', [CreateProjectController::class, 'getAmbits']); - - - -// Route::controller(CreateProjectController::class) -// ->group(function () { - -// Route::post('receiveEquipmentToAssociateTasks', [CreateProjectController::class, 'receiveEquipmentToAssociateTasks'])->name('receiveEquipmentToAssociateTasks'); -// Route::get('finishCreatingProject/{numberProject}', [CreateProjectController::class, 'finishCreatingProject'])->name('finishCreatingProject'); -// Route::get('testDataTables', [CreateProjectController::class, 'testDataTables'])->name('testDataTables'); -// Route::get('workstationsAssociationTasks', [CreateProjectController::class, 'workstationsAssociationTasks'])->name('workstationsAssociationTasks'); -// Route::get('AddNomenclatureWorkstation', [CreateProjectController::class, 'AddNomenclatureWorkstation'])->name('AddNomenclatureWorkstation'); -// Route::get('removeProjectEquipment', [CreateProjectController::class, 'removeProjectEquipment'])->name('removeProjectEquipment'); -// Route::delete('deleteWorkstation/{name}', [CreateProjectController::class, 'deleteWorkstation'])->name('deleteWorkstation'); -// Route::post('/EditEquipmentsProjects', [CreateProjectController::class, 'EditEquipmentsProjects'])->name('EditEquipmentsProjects'); -// Route::get('/createProject', [CreateProjectController::class, 'createProjectForStep1'])->name('createProject'); -// Route::post('/newProject1', [CreateProjectController::class, 'processStep1'])->name('processStep1'); -// Route::post('/createWorkStations', [CreateProjectController::class, 'createWorkStations'])->name('createWorkStations'); -// Route::get('/test1/{id}', [CreateProjectController::class, 'showStep1'])->name('test1'); -// Route::get('/test2/{id}', [CreateProjectController::class, 'showStep2'])->name('test2'); -// Route::get('/test3/{id}', [CreateProjectController::class, 'showStep3'])->name('test3'); -// Route::post('test1', [CreateProjectController::class, 'EditprocessStep1'])->name('EditprocessStep1'); -// Route::post('/test2', [CreateProjectController::class, 'processStep2'])->name('processStep2'); -// Route::post('/test2CreateEquipment', [CreateProjectController::class, 'createEquipmentManual'])->name('test2CreateEquipment'); -// Route::post('/test3', [CreateProjectController::class, 'processStep3']); -// Route::delete('/removeEquipment/{id}', [CreateProjectController::class, 'removePendingEquipment'])->name('removeEquipment'); -// Route::post('CreateNewEquipmentFromPendingEquipment/{id}', [CreateProjectController::class, 'CreateNewEquipmentFromPendingEquipment'])->name('CreateNewEquipmentFromPendingEquipment'); -// Route::get('/template1/{numberProject}', [CreateProjectController::class, 'receiveUnitsForExcelTemplate'])->name('download'); -// Route::post('/create-equipament-project', [CreateProjectController::class, 'createEquipamentProject'])->name('createEquipamentProject'); -// Route::get('/equipments/{id}/attributes', 'getAttributes'); -// }); \ No newline at end of file +Route::get('/api/ambits/{equipmentType}', [CreateProjectController::class, 'getAmbits']); \ No newline at end of file