From fef381f4d5221bfb1c7b8929fef7b6412355ab89 Mon Sep 17 00:00:00 2001 From: Lucas Ramalho Date: Sun, 14 Dec 2025 21:26:46 -0300 Subject: [PATCH 01/16] Adicionado ULID para user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ULID adicionado também nos relacionamentos onde user está presente --- .scribe/endpoints.cache/01.yaml | 519 +- .scribe/endpoints.cache/02.yaml | 459 ++ .scribe/endpoints/01.yaml | 519 +- .scribe/endpoints/02.yaml | 457 ++ app/Http/Controllers/AuthController.php | 6 +- app/Http/Controllers/ContentController.php | 12 +- .../Controllers/ContentTypeController.php | 14 +- app/Http/Controllers/SystemUserController.php | 105 +- app/Http/Requests/ChangeStatusSystemUser.php | 28 + app/Http/Requests/RegisterUserRequest.php | 4 +- app/Http/Requests/StoreContent.php | 2 +- app/Http/Requests/StoreSystemUserRequest.php | 35 +- .../Requests/UpdateSystemUserPassword.php | 10 + app/Http/Requests/UpdateSystemUserRequest.php | 16 +- app/Models/Content.php | 17 +- app/Models/ContentTag.php | 9 +- app/Models/ContentType.php | 8 +- app/Models/Materias.php | 8 +- app/Models/Question.php | 6 +- app/Models/SystemUser.php | 65 +- app/Policies/ContentPolicy.php | 10 +- app/Policies/SystemUserPolicy.php | 81 +- database/factories/AlternativeFactory.php | 4 +- database/factories/ContentFactory.php | 8 +- database/factories/ContentTagFactory.php | 6 +- database/factories/ContentTypeFactory.php | 6 +- database/factories/MateriasFactory.php | 4 +- .../factories/QuestionCollectionFactory.php | 2 +- database/factories/QuestionFactory.php | 6 +- database/factories/SystemUserFactory.php | 8 +- ...09_23_123300_create_system_users_table.php | 27 +- ...9_23_123305_create_content_types_table.php | 21 +- ...025_09_23_123310_create_materias_table.php | 10 +- ...09_23_123312_create_content_tags_table.php | 21 +- ...2025_09_23_123320_create_content_table.php | 29 +- ...025_09_23_165457_create_questoes_table.php | 12 +- ...09_23_170149_create_alternativas_table.php | 8 +- .../2025_09_23_170416_create_turmas_table.php | 10 +- ...09_23_170916_create_turma_alunos_table.php | 10 +- ...174312_create_question_colletion_table.php | 4 +- ..._23_174805_create_class_activity_table.php | 4 +- ..._174906_create_question_activity_table.php | 4 +- ...3346_add_status_to_content_types_table.php | 28 - ...03624_add_status_to_content_tags_table.php | 28 - ...08_031640_create_student_answers_table.php | 4 +- database/seeders/SystemUserSeeder.php | 24 +- resources/views/scribe/index.blade.php | 6221 +++++++++-------- storage/app/private/scribe/collection.json | 830 +-- storage/app/private/scribe/openapi.yaml | 493 +- 49 files changed, 5237 insertions(+), 4985 deletions(-) create mode 100644 .scribe/endpoints.cache/02.yaml create mode 100644 .scribe/endpoints/02.yaml create mode 100644 app/Http/Requests/ChangeStatusSystemUser.php delete mode 100644 database/migrations/2025_10_27_203346_add_status_to_content_types_table.php delete mode 100644 database/migrations/2025_10_27_203624_add_status_to_content_tags_table.php diff --git a/.scribe/endpoints.cache/01.yaml b/.scribe/endpoints.cache/01.yaml index 53763c6..23eb2df 100644 --- a/.scribe/endpoints.cache/01.yaml +++ b/.scribe/endpoints.cache/01.yaml @@ -372,453 +372,6 @@ endpoints: controller: null method: null route: null - - - custom: [] - httpMethods: - - PUT - uri: 'api/users/{user_id}/password' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - user_id: - custom: [] - name: user_id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - user_id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - password: - custom: [] - name: password - description: 'Must be at least 8 characters.' - required: true - example: '|]|{+-' - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - password: '|]|{+-' - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - GET - uri: api/users - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: [] - cleanUrlParameters: [] - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: - - - custom: [] - status: 401 - content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' - headers: - cache-control: 'no-cache, private' - content-type: application/json - access-control-allow-origin: '*' - description: null - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - POST - uri: api/users - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Store a newly created resource in storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: [] - cleanUrlParameters: [] - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - nome: - custom: [] - name: nome - description: 'Must not be greater than 255 characters.' - required: true - example: b - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - email: - custom: [] - name: email - description: 'Must be a valid email address. Must not be greater than 100 characters.' - required: true - example: zbailey@example.net - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - password: - custom: [] - name: password - description: 'Must be at least 8 characters.' - required: true - example: '-0pBNvYgxw' - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - tipo: - custom: [] - name: tipo - description: '' - required: true - example: Operador - type: string - enumValues: - - Professor - - Aluno - - ADM - - Moderador - - Operador - exampleWasSpecified: false - nullable: false - deprecated: false - status: - custom: [] - name: status - description: '' - required: false - example: Ativo - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - nome: b - email: zbailey@example.net - password: '-0pBNvYgxw' - tipo: Operador - status: Ativo - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - GET - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Display the specified resource.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: - - - custom: [] - status: 401 - content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' - headers: - cache-control: 'no-cache, private' - content-type: application/json - access-control-allow-origin: '*' - description: null - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - PUT - - PATCH - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Update the specified resource in storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - nome: - custom: [] - name: nome - description: 'Must not be greater than 255 characters.' - required: false - example: b - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - email: - custom: [] - name: email - description: 'Must be a valid email address. Must not be greater than 100 characters.' - required: false - example: zbailey@example.net - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - tipo: - custom: [] - name: tipo - description: '' - required: false - example: Moderador - type: string - enumValues: - - Professor - - Aluno - - ADM - - Moderador - - Operador - exampleWasSpecified: false - nullable: false - deprecated: false - status: - custom: [] - name: status - description: '' - required: false - example: Ativo - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - nome: b - email: zbailey@example.net - tipo: Moderador - status: Ativo - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - DELETE - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Remove the specified resource from storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - PATCH - uri: 'api/users/{user_id}/status' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - user_id: - custom: [] - name: user_id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - user_id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - status: - custom: [] - name: status - description: '' - required: true - example: Bloqueado - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - status: Bloqueado - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - custom: [] httpMethods: @@ -1214,7 +767,7 @@ endpoints: name: status description: '' required: true - example: Ativo + example: Rascunho type: string enumValues: - Ativo @@ -1224,7 +777,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Ativo + status: Rascunho fileParameters: [] responses: [] responseFields: [] @@ -1330,7 +883,7 @@ endpoints: name: published_at description: 'Must be a valid date.' required: false - example: '2025-11-28T03:44:56' + example: '2025-12-14T21:56:08' type: string enumValues: [] exampleWasSpecified: false @@ -1341,7 +894,7 @@ endpoints: name: is_moderator_only description: '' required: false - example: false + example: true type: boolean enumValues: [] exampleWasSpecified: false @@ -1403,8 +956,8 @@ endpoints: tag_name: g description: 'Quos velit et fugiat sunt nihil accusantium harum.' status: Rascunho - published_at: '2025-11-28T03:44:56' - is_moderator_only: false + published_at: '2025-12-14T21:56:08' + is_moderator_only: true images: - architecto image_alt_text: @@ -1523,7 +1076,7 @@ endpoints: name: status description: '' required: false - example: Ativo + example: Rascunho type: string enumValues: - Ativo @@ -1537,7 +1090,7 @@ endpoints: name: published_at description: 'Must be a valid date.' required: false - example: '2025-11-28T03:44:56' + example: '2025-12-14T21:56:08' type: string enumValues: [] exampleWasSpecified: false @@ -1585,8 +1138,8 @@ endpoints: content_type_description: architecto content_tag: 'n' content_tag_description: architecto - status: Ativo - published_at: '2025-11-28T03:44:56' + status: Rascunho + published_at: '2025-12-14T21:56:08' is_moderator_only: false images: - architecto @@ -1957,7 +1510,7 @@ endpoints: name: status description: '' required: true - example: Inativo + example: Ativo type: string enumValues: - Ativo @@ -1966,7 +1519,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Inativo + status: Ativo fileParameters: [] responses: [] responseFields: [] @@ -2024,7 +1577,7 @@ endpoints: name: is_moderator_only description: '' required: true - example: false + example: true type: boolean enumValues: [] exampleWasSpecified: false @@ -2044,7 +1597,7 @@ endpoints: cleanBodyParameters: tag_name: b description: 'Et animi quos velit et fugiat.' - is_moderator_only: false + is_moderator_only: true count: 16 fileParameters: [] responses: [] @@ -2256,7 +1809,7 @@ endpoints: name: status description: '' required: true - example: Active + example: Inactive type: string enumValues: - Inactive @@ -2265,7 +1818,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Active + status: Inactive fileParameters: [] responses: [] responseFields: [] @@ -2345,7 +1898,7 @@ endpoints: name: type description: '' required: true - example: Multipla + example: Aberta type: string enumValues: - Multipla @@ -2382,7 +1935,7 @@ endpoints: name: 'alternatives[].correct' description: '' required: true - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2393,11 +1946,11 @@ endpoints: content: architecto correction: architecto materia: 16 - type: Multipla + type: Aberta alternatives: - content: b - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -2589,7 +2142,7 @@ endpoints: name: 'alternatives[].correct' description: '' required: false - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2604,7 +2157,7 @@ endpoints: alternatives: - content: 'n' - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -2695,7 +2248,7 @@ endpoints: name: status description: '' required: true - example: Active + example: Inactive type: string enumValues: - Active @@ -2704,7 +2257,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Active + status: Inactive fileParameters: [] responses: [] responseFields: [] @@ -2788,7 +2341,7 @@ endpoints: name: due_date description: 'Must be a valid date. Must be a date after now.' required: false - example: '2051-12-22' + example: '2052-01-08' type: string enumValues: [] exampleWasSpecified: false @@ -2918,7 +2471,7 @@ endpoints: name: 'questions[].alternatives[].correct' description: '' required: true - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2929,7 +2482,7 @@ endpoints: description: 'Et animi quos velit et fugiat.' subject_id: architecto type: Simulation - due_date: '2051-12-22' + due_date: '2052-01-08' status: Active questions: - @@ -2942,7 +2495,7 @@ endpoints: alternatives: - content: architecto - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -3024,7 +2577,7 @@ endpoints: name: type description: '' required: false - example: Exercise + example: Exam type: string enumValues: - Exam @@ -3039,7 +2592,7 @@ endpoints: name: due_date description: 'Must be a valid date. Must be a date after now.' required: false - example: '2051-12-22' + example: '2052-01-08' type: string enumValues: [] exampleWasSpecified: false @@ -3118,7 +2671,7 @@ endpoints: name: 'questions[].type' description: '' required: false - example: Aberta + example: VerdadeiroFalso type: string enumValues: - Multipla @@ -3132,7 +2685,7 @@ endpoints: name: 'questions[].status' description: '' required: false - example: Active + example: Inactive type: string enumValues: - Active @@ -3187,8 +2740,8 @@ endpoints: cleanBodyParameters: title: b description: 'Et animi quos velit et fugiat.' - type: Exercise - due_date: '2051-12-22' + type: Exam + due_date: '2052-01-08' status: Inactive questions: - @@ -3196,8 +2749,8 @@ endpoints: title: 'n' content: architecto correction: architecto - type: Aberta - status: Active + type: VerdadeiroFalso + status: Inactive alternatives: - content: 'n' diff --git a/.scribe/endpoints.cache/02.yaml b/.scribe/endpoints.cache/02.yaml new file mode 100644 index 0000000..8133179 --- /dev/null +++ b/.scribe/endpoints.cache/02.yaml @@ -0,0 +1,459 @@ +## Autogenerated by Scribe. DO NOT MODIFY. + +name: Usuários +description: |- + Filtros disponíveis: + - name: Filtra por nome (fullText) + - email: Filtra por email (fullText) + - role: Filtra por tipo de usuário + - status: Filtra por status do usuário + - created_at: Filtra por data de criação + - updated_at: Filtra por data de atualização + - deleted_at: Filtra por data de exclusão + - created_by: Filtra por ID do criador + - updated_by: Filtra por ID do último editor + - search: Busca geral em nome e email +endpoints: + - + custom: [] + httpMethods: + - PUT + uri: 'api/users/{user_id}/password' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'updatePassword: Atualiza a senha de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + user_id: + custom: [] + name: user_id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + user_id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + password: + custom: [] + name: password + description: 'Must be at least 8 characters.' + required: true + example: '|]|{+-' + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + password: '|]|{+-' + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - GET + uri: api/users + metadata: + custom: [] + groupName: Usuários + groupDescription: |- + Filtros disponíveis: + - name: Filtra por nome (fullText) + - email: Filtra por email (fullText) + - role: Filtra por tipo de usuário + - status: Filtra por status do usuário + - created_at: Filtra por data de criação + - updated_at: Filtra por data de atualização + - deleted_at: Filtra por data de exclusão + - created_by: Filtra por ID do criador + - updated_by: Filtra por ID do último editor + - search: Busca geral em nome e email + subgroup: '' + subgroupDescription: '' + title: 'Index: Retorna uma lista paginada de usuários do sistema com filtros opcionais.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: [] + cleanUrlParameters: [] + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: + - + custom: [] + status: 401 + content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' + headers: + cache-control: 'no-cache, private' + content-type: application/json + access-control-allow-origin: '*' + description: null + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - POST + uri: api/users + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Store: Cria um novo usuário do sistema, criador por: ADMIN, moderador ou operador.' + description: 'OBS.: Não é self-registration.' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: [] + cleanUrlParameters: [] + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + name: + custom: [] + name: name + description: 'Must not be greater than 255 characters.' + required: true + example: b + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + email: + custom: [] + name: email + description: 'Must be a valid email address. Must not be greater than 100 characters.' + required: true + example: zbailey@example.net + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + password: + custom: [] + name: password + description: 'Must be at least 8 characters.' + required: true + example: '-0pBNvYgxw' + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + role: + custom: [] + name: role + description: '' + required: true + example: admin + type: string + enumValues: + - teacher + - student + - admin + - moderator + - operator + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + name: b + email: zbailey@example.net + password: '-0pBNvYgxw' + role: admin + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - GET + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Show: Retorna os detalhes de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: + - + custom: [] + status: 401 + content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' + headers: + cache-control: 'no-cache, private' + content-type: application/json + access-control-allow-origin: '*' + description: null + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - PUT + - PATCH + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'update: Atualiza os dados de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + nome: + custom: [] + name: nome + description: 'Must not be greater than 255 characters.' + required: false + example: b + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + email: + custom: [] + name: email + description: 'Must be a valid email address. Must not be greater than 100 characters.' + required: false + example: zbailey@example.net + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + tipo: + custom: [] + name: tipo + description: '' + required: false + example: Professor + type: string + enumValues: + - Professor + - Aluno + - ADM + - Moderador + - Operador + exampleWasSpecified: false + nullable: false + deprecated: false + status: + custom: [] + name: status + description: '' + required: false + example: Inativo + type: string + enumValues: + - Ativo + - Inativo + - Bloqueado + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + nome: b + email: zbailey@example.net + tipo: Professor + status: Inativo + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - DELETE + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Destroy: Remove um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - PATCH + uri: 'api/users/{user_id}/status' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'changeStatus: Altera o status de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + user_id: + custom: [] + name: user_id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + user_id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + status: + custom: [] + name: status + description: '' + required: true + example: active + type: string + enumValues: + - active + - inactive + - blocked + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + status: active + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null diff --git a/.scribe/endpoints/01.yaml b/.scribe/endpoints/01.yaml index 2a236ef..ab079e9 100644 --- a/.scribe/endpoints/01.yaml +++ b/.scribe/endpoints/01.yaml @@ -370,453 +370,6 @@ endpoints: controller: null method: null route: null - - - custom: [] - httpMethods: - - PUT - uri: 'api/users/{user_id}/password' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - user_id: - custom: [] - name: user_id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - user_id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - password: - custom: [] - name: password - description: 'Must be at least 8 characters.' - required: true - example: '|]|{+-' - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - password: '|]|{+-' - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - GET - uri: api/users - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: [] - cleanUrlParameters: [] - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: - - - custom: [] - status: 401 - content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' - headers: - cache-control: 'no-cache, private' - content-type: application/json - access-control-allow-origin: '*' - description: null - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - POST - uri: api/users - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Store a newly created resource in storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: [] - cleanUrlParameters: [] - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - nome: - custom: [] - name: nome - description: 'Must not be greater than 255 characters.' - required: true - example: b - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - email: - custom: [] - name: email - description: 'Must be a valid email address. Must not be greater than 100 characters.' - required: true - example: zbailey@example.net - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - password: - custom: [] - name: password - description: 'Must be at least 8 characters.' - required: true - example: '-0pBNvYgxw' - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - tipo: - custom: [] - name: tipo - description: '' - required: true - example: Operador - type: string - enumValues: - - Professor - - Aluno - - ADM - - Moderador - - Operador - exampleWasSpecified: false - nullable: false - deprecated: false - status: - custom: [] - name: status - description: '' - required: false - example: Ativo - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - nome: b - email: zbailey@example.net - password: '-0pBNvYgxw' - tipo: Operador - status: Ativo - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - GET - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Display the specified resource.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: - - - custom: [] - status: 401 - content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' - headers: - cache-control: 'no-cache, private' - content-type: application/json - access-control-allow-origin: '*' - description: null - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - PUT - - PATCH - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Update the specified resource in storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - nome: - custom: [] - name: nome - description: 'Must not be greater than 255 characters.' - required: false - example: b - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - email: - custom: [] - name: email - description: 'Must be a valid email address. Must not be greater than 100 characters.' - required: false - example: zbailey@example.net - type: string - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - tipo: - custom: [] - name: tipo - description: '' - required: false - example: Moderador - type: string - enumValues: - - Professor - - Aluno - - ADM - - Moderador - - Operador - exampleWasSpecified: false - nullable: false - deprecated: false - status: - custom: [] - name: status - description: '' - required: false - example: Ativo - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - nome: b - email: zbailey@example.net - tipo: Moderador - status: Ativo - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - DELETE - uri: 'api/users/{id}' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: 'Remove the specified resource from storage.' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - id: - custom: [] - name: id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: [] - cleanBodyParameters: [] - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - - - custom: [] - httpMethods: - - PATCH - uri: 'api/users/{user_id}/status' - metadata: - custom: [] - groupName: Endpoints - groupDescription: '' - subgroup: '' - subgroupDescription: '' - title: '' - description: '' - authenticated: false - deprecated: false - headers: - Content-Type: application/json - Accept: application/json - urlParameters: - user_id: - custom: [] - name: user_id - description: 'The ID of the user.' - required: true - example: 1 - type: integer - enumValues: [] - exampleWasSpecified: false - nullable: false - deprecated: false - cleanUrlParameters: - user_id: 1 - queryParameters: [] - cleanQueryParameters: [] - bodyParameters: - status: - custom: [] - name: status - description: '' - required: true - example: Bloqueado - type: string - enumValues: - - Ativo - - Inativo - - Bloqueado - exampleWasSpecified: false - nullable: false - deprecated: false - cleanBodyParameters: - status: Bloqueado - fileParameters: [] - responses: [] - responseFields: [] - auth: [] - controller: null - method: null - route: null - custom: [] httpMethods: @@ -1212,7 +765,7 @@ endpoints: name: status description: '' required: true - example: Ativo + example: Rascunho type: string enumValues: - Ativo @@ -1222,7 +775,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Ativo + status: Rascunho fileParameters: [] responses: [] responseFields: [] @@ -1328,7 +881,7 @@ endpoints: name: published_at description: 'Must be a valid date.' required: false - example: '2025-11-28T03:44:56' + example: '2025-12-14T21:56:08' type: string enumValues: [] exampleWasSpecified: false @@ -1339,7 +892,7 @@ endpoints: name: is_moderator_only description: '' required: false - example: false + example: true type: boolean enumValues: [] exampleWasSpecified: false @@ -1401,8 +954,8 @@ endpoints: tag_name: g description: 'Quos velit et fugiat sunt nihil accusantium harum.' status: Rascunho - published_at: '2025-11-28T03:44:56' - is_moderator_only: false + published_at: '2025-12-14T21:56:08' + is_moderator_only: true images: - architecto image_alt_text: @@ -1521,7 +1074,7 @@ endpoints: name: status description: '' required: false - example: Ativo + example: Rascunho type: string enumValues: - Ativo @@ -1535,7 +1088,7 @@ endpoints: name: published_at description: 'Must be a valid date.' required: false - example: '2025-11-28T03:44:56' + example: '2025-12-14T21:56:08' type: string enumValues: [] exampleWasSpecified: false @@ -1583,8 +1136,8 @@ endpoints: content_type_description: architecto content_tag: 'n' content_tag_description: architecto - status: Ativo - published_at: '2025-11-28T03:44:56' + status: Rascunho + published_at: '2025-12-14T21:56:08' is_moderator_only: false images: - architecto @@ -1955,7 +1508,7 @@ endpoints: name: status description: '' required: true - example: Inativo + example: Ativo type: string enumValues: - Ativo @@ -1964,7 +1517,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Inativo + status: Ativo fileParameters: [] responses: [] responseFields: [] @@ -2022,7 +1575,7 @@ endpoints: name: is_moderator_only description: '' required: true - example: false + example: true type: boolean enumValues: [] exampleWasSpecified: false @@ -2042,7 +1595,7 @@ endpoints: cleanBodyParameters: tag_name: b description: 'Et animi quos velit et fugiat.' - is_moderator_only: false + is_moderator_only: true count: 16 fileParameters: [] responses: [] @@ -2254,7 +1807,7 @@ endpoints: name: status description: '' required: true - example: Active + example: Inactive type: string enumValues: - Inactive @@ -2263,7 +1816,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Active + status: Inactive fileParameters: [] responses: [] responseFields: [] @@ -2343,7 +1896,7 @@ endpoints: name: type description: '' required: true - example: Multipla + example: Aberta type: string enumValues: - Multipla @@ -2380,7 +1933,7 @@ endpoints: name: 'alternatives[].correct' description: '' required: true - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2391,11 +1944,11 @@ endpoints: content: architecto correction: architecto materia: 16 - type: Multipla + type: Aberta alternatives: - content: b - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -2587,7 +2140,7 @@ endpoints: name: 'alternatives[].correct' description: '' required: false - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2602,7 +2155,7 @@ endpoints: alternatives: - content: 'n' - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -2693,7 +2246,7 @@ endpoints: name: status description: '' required: true - example: Active + example: Inactive type: string enumValues: - Active @@ -2702,7 +2255,7 @@ endpoints: nullable: false deprecated: false cleanBodyParameters: - status: Active + status: Inactive fileParameters: [] responses: [] responseFields: [] @@ -2786,7 +2339,7 @@ endpoints: name: due_date description: 'Must be a valid date. Must be a date after now.' required: false - example: '2051-12-22' + example: '2052-01-08' type: string enumValues: [] exampleWasSpecified: false @@ -2916,7 +2469,7 @@ endpoints: name: 'questions[].alternatives[].correct' description: '' required: true - example: true + example: false type: boolean enumValues: [] exampleWasSpecified: false @@ -2927,7 +2480,7 @@ endpoints: description: 'Et animi quos velit et fugiat.' subject_id: architecto type: Simulation - due_date: '2051-12-22' + due_date: '2052-01-08' status: Active questions: - @@ -2940,7 +2493,7 @@ endpoints: alternatives: - content: architecto - correct: true + correct: false fileParameters: [] responses: [] responseFields: [] @@ -3022,7 +2575,7 @@ endpoints: name: type description: '' required: false - example: Exercise + example: Exam type: string enumValues: - Exam @@ -3037,7 +2590,7 @@ endpoints: name: due_date description: 'Must be a valid date. Must be a date after now.' required: false - example: '2051-12-22' + example: '2052-01-08' type: string enumValues: [] exampleWasSpecified: false @@ -3116,7 +2669,7 @@ endpoints: name: 'questions[].type' description: '' required: false - example: Aberta + example: VerdadeiroFalso type: string enumValues: - Multipla @@ -3130,7 +2683,7 @@ endpoints: name: 'questions[].status' description: '' required: false - example: Active + example: Inactive type: string enumValues: - Active @@ -3185,8 +2738,8 @@ endpoints: cleanBodyParameters: title: b description: 'Et animi quos velit et fugiat.' - type: Exercise - due_date: '2051-12-22' + type: Exam + due_date: '2052-01-08' status: Inactive questions: - @@ -3194,8 +2747,8 @@ endpoints: title: 'n' content: architecto correction: architecto - type: Aberta - status: Active + type: VerdadeiroFalso + status: Inactive alternatives: - content: 'n' diff --git a/.scribe/endpoints/02.yaml b/.scribe/endpoints/02.yaml new file mode 100644 index 0000000..bdf1705 --- /dev/null +++ b/.scribe/endpoints/02.yaml @@ -0,0 +1,457 @@ +name: Usuários +description: |- + Filtros disponíveis: + - name: Filtra por nome (fullText) + - email: Filtra por email (fullText) + - role: Filtra por tipo de usuário + - status: Filtra por status do usuário + - created_at: Filtra por data de criação + - updated_at: Filtra por data de atualização + - deleted_at: Filtra por data de exclusão + - created_by: Filtra por ID do criador + - updated_by: Filtra por ID do último editor + - search: Busca geral em nome e email +endpoints: + - + custom: [] + httpMethods: + - PUT + uri: 'api/users/{user_id}/password' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'updatePassword: Atualiza a senha de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + user_id: + custom: [] + name: user_id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + user_id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + password: + custom: [] + name: password + description: 'Must be at least 8 characters.' + required: true + example: '|]|{+-' + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + password: '|]|{+-' + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - GET + uri: api/users + metadata: + custom: [] + groupName: Usuários + groupDescription: |- + Filtros disponíveis: + - name: Filtra por nome (fullText) + - email: Filtra por email (fullText) + - role: Filtra por tipo de usuário + - status: Filtra por status do usuário + - created_at: Filtra por data de criação + - updated_at: Filtra por data de atualização + - deleted_at: Filtra por data de exclusão + - created_by: Filtra por ID do criador + - updated_by: Filtra por ID do último editor + - search: Busca geral em nome e email + subgroup: '' + subgroupDescription: '' + title: 'Index: Retorna uma lista paginada de usuários do sistema com filtros opcionais.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: [] + cleanUrlParameters: [] + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: + - + custom: [] + status: 401 + content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' + headers: + cache-control: 'no-cache, private' + content-type: application/json + access-control-allow-origin: '*' + description: null + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - POST + uri: api/users + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Store: Cria um novo usuário do sistema, criador por: ADMIN, moderador ou operador.' + description: 'OBS.: Não é self-registration.' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: [] + cleanUrlParameters: [] + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + name: + custom: [] + name: name + description: 'Must not be greater than 255 characters.' + required: true + example: b + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + email: + custom: [] + name: email + description: 'Must be a valid email address. Must not be greater than 100 characters.' + required: true + example: zbailey@example.net + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + password: + custom: [] + name: password + description: 'Must be at least 8 characters.' + required: true + example: '-0pBNvYgxw' + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + role: + custom: [] + name: role + description: '' + required: true + example: admin + type: string + enumValues: + - teacher + - student + - admin + - moderator + - operator + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + name: b + email: zbailey@example.net + password: '-0pBNvYgxw' + role: admin + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - GET + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Show: Retorna os detalhes de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: + - + custom: [] + status: 401 + content: '{"success":false,"message":"N\u00e3o autenticado. Token inv\u00e1lido ou ausente."}' + headers: + cache-control: 'no-cache, private' + content-type: application/json + access-control-allow-origin: '*' + description: null + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - PUT + - PATCH + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'update: Atualiza os dados de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + nome: + custom: [] + name: nome + description: 'Must not be greater than 255 characters.' + required: false + example: b + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + email: + custom: [] + name: email + description: 'Must be a valid email address. Must not be greater than 100 characters.' + required: false + example: zbailey@example.net + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + tipo: + custom: [] + name: tipo + description: '' + required: false + example: Professor + type: string + enumValues: + - Professor + - Aluno + - ADM + - Moderador + - Operador + exampleWasSpecified: false + nullable: false + deprecated: false + status: + custom: [] + name: status + description: '' + required: false + example: Inativo + type: string + enumValues: + - Ativo + - Inativo + - Bloqueado + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + nome: b + email: zbailey@example.net + tipo: Professor + status: Inativo + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - DELETE + uri: 'api/users/{id}' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'Destroy: Remove um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + id: + custom: [] + name: id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: [] + cleanBodyParameters: [] + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null + - + custom: [] + httpMethods: + - PATCH + uri: 'api/users/{user_id}/status' + metadata: + custom: [] + groupName: Usuários + groupDescription: '' + subgroup: '' + subgroupDescription: '' + title: 'changeStatus: Altera o status de um usuário do sistema.' + description: '' + authenticated: false + deprecated: false + headers: + Content-Type: application/json + Accept: application/json + urlParameters: + user_id: + custom: [] + name: user_id + description: 'The ID of the user.' + required: true + example: 1 + type: string + enumValues: [] + exampleWasSpecified: false + nullable: false + deprecated: false + cleanUrlParameters: + user_id: 1 + queryParameters: [] + cleanQueryParameters: [] + bodyParameters: + status: + custom: [] + name: status + description: '' + required: true + example: active + type: string + enumValues: + - active + - inactive + - blocked + exampleWasSpecified: false + nullable: false + deprecated: false + cleanBodyParameters: + status: active + fileParameters: [] + responses: [] + responseFields: [] + auth: [] + controller: null + method: null + route: null diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 32dccda..bda36d2 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -131,17 +131,17 @@ public function login(LoginUserRequest $request) ], 401); } - if ($user->status !== 'Ativo') { + if ($user->status !== 'active') { return response()->json([ 'success' => false, 'message' => 'Usuário inativo', ], 403); } - if ($user->status === 'Bloqueado') { + if ($user->status === 'banned') { return response()->json([ 'success' => false, - 'message' => 'Usuário bloqueado', + 'message' => 'Usuário Banido', ], 403); } diff --git a/app/Http/Controllers/ContentController.php b/app/Http/Controllers/ContentController.php index c417391..b2e8eab 100644 --- a/app/Http/Controllers/ContentController.php +++ b/app/Http/Controllers/ContentController.php @@ -56,18 +56,18 @@ public function store(StoreContent $request) ['title' => $validated['content_type']], [ 'description' => $validated['content_type_description'] ?? '', - 'criador' => $user->id, + 'created_by' => $user->id, ] ); $conteudo = Content::create([ 'title' => $validated['title'], - 'content' => $validated['content'], + 'body' => $validated['body'], 'content_types_id' => $contentType->id, 'id_materia' => null, 'status' => $validated['status'], 'published_at' => $validated['published_at'], - 'criador' => $user->id, + 'created_by' => $user->id, ]); if (! empty($validated['content_tags'])) { @@ -148,7 +148,7 @@ public function update(UpdateContentRequest $request, Content $content): JsonRes try { $validated = $request->validated(); - $validated['ultimo_editor'] = Auth::id(); + $validated['updated_by'] = Auth::id(); $content->update($validated); @@ -215,11 +215,11 @@ public function changeStatus(ChangeStatusContentRequest $request, Content $conte try { $validated = $request->validated(); - $validated['ultimo_editor'] = Auth::id(); + $validated['updated_by'] = Auth::id(); $content->update([ 'status' => $validated['status'], - 'ultimo_editor' => $validated['ultimo_editor'], + 'updated_by' => $validated['updated_by'], ]); return response()->json([ diff --git a/app/Http/Controllers/ContentTypeController.php b/app/Http/Controllers/ContentTypeController.php index e27ab0b..4906bd4 100644 --- a/app/Http/Controllers/ContentTypeController.php +++ b/app/Http/Controllers/ContentTypeController.php @@ -44,9 +44,9 @@ public function store(StoreContentType $request) $user = Auth::user(); - $validated['criador'] = $user->id; + $validated['created_by'] = $user->id; - $validated['ultimo_editor'] = $user->id; + $validated['updated_by'] = $user->id; $contentType = ContentType::create($validated); @@ -72,7 +72,7 @@ public function show(ContentType $contentType) { return response()->json([ 'success' => true, - 'data' => $contentType->load(['creator', 'lastEditor']), + 'data' => $contentType->load(['creator', 'updater']), ]); } @@ -87,9 +87,9 @@ public function update(UpdateContentTypeRequest $request, ContentType $contentTy $user = Auth::user(); - $validated['criador'] = $user->id; + $validated['created_by'] = $user->id; - $validated['ultimo_editor'] = $user->id; + $validated['updated_by'] = $user->id; $contentType->update($validated); @@ -115,7 +115,7 @@ public function destroy(ContentType $contentType) try { $user = Auth::user(); - if (! ($user && $user->tipo === 'ADM')) { + if (! ($user && $user->tipo === 'admin')) { return response()->json([ 'success' => false, 'message' => 'Acesso negado', @@ -145,7 +145,7 @@ public function changeStatus(ChangeStatusContentTypeRequest $request, ContentTyp $contentType->update([ 'status' => $validated['status'], - 'ultimo_editor' => $user->id, + 'updated_by' => $user->id, ]); $contentType->refresh(); diff --git a/app/Http/Controllers/SystemUserController.php b/app/Http/Controllers/SystemUserController.php index f43f5bd..ddd6159 100755 --- a/app/Http/Controllers/SystemUserController.php +++ b/app/Http/Controllers/SystemUserController.php @@ -15,25 +15,70 @@ class SystemUserController extends Controller { use AuthorizesRequests; + /** + * Index: Retorna uma lista paginada de usuários do sistema com filtros opcionais. + * + * @group Usuários + * + * Filtros disponíveis: + * - name: Filtra por nome (fullText) + * - email: Filtra por email (fullText) + * - role: Filtra por tipo de usuário + * - status: Filtra por status do usuário + * - created_at: Filtra por data de criação + * - updated_at: Filtra por data de atualização + * - deleted_at: Filtra por data de exclusão + * - created_by: Filtra por ID do criador + * - updated_by: Filtra por ID do último editor + * - search: Busca geral em nome e email + */ public function index(Request $request): JsonResponse { $this->authorize('viewAny', SystemUser::class); - $query = SystemUser::with(['creator', 'lastEditor']); + $query = SystemUser::with(['creator', 'updater']); + + if ($request->has('name')) { + $query->name($request->input('name')); + } + + if ($request->has('email')) { + $query->email($request->input('email')); + } - if ($request->has('tipo')) { - $query->where('tipo', $request->input('tipo')); + if ($request->has('role')) { + $query->role($request->input('role')); } if ($request->has('status')) { - $query->where('status', $request->input('status')); - } // usar input como padrõa para coleta de dados dos requests + $query->status($request->input('status')); + } + + if ($request->has('created_at')) { + $query->createdAt($request->input('created_at')); + } + + if ($request->has('updated_at')) { + $query->updatedAt($request->input('updated_at')); + } + + if ($request->has('deleted_at')) { + $query->deletedAt($request->input('deleted_at')); + } + + if ($request->has('created_by')) { + $query->createdBy($request->input('created_by')); + } + + if ($request->has('updated_by')) { + $query->updatedBy($request->input('updated_by')); + } if ($request->has('search')) { $search = $request->input('search'); $query->where(function ($q) use ($search) { - $q->where('nome', 'like', "%{$search}%") - ->orWhere('email', 'like', "%{$search}%"); + $q->name($search) + ->orWhereFullText('email', $search); }); } @@ -46,7 +91,10 @@ public function index(Request $request): JsonResponse } /** - * Store a newly created resource in storage. + * Store: Cria um novo usuário do sistema, criador por: ADMIN, moderador ou operador. + * OBS.: Não é self-registration. + * + * @group Usuários */ public function store(StoreSystemUserRequest $request): JsonResponse { @@ -58,9 +106,9 @@ public function store(StoreSystemUserRequest $request): JsonResponse $user = Auth::user(); - $validated['criador'] = $user->id; + $validated['creator'] = $user->id; - $validated['ultimo_editor'] = $user->id; + $validated['updater'] = $user->id; if (! empty($validated['password'])) { $validated['password'] = bcrypt($validated['password']); @@ -71,7 +119,7 @@ public function store(StoreSystemUserRequest $request): JsonResponse return response()->json([ 'success' => true, 'message' => 'Usuário criado com sucesso', - 'data' => $user->load(['creator', 'lastEditor']), + 'data' => $user->load(['creator', 'updater']), ], 201); } catch (\Exception $e) { return response()->json([ @@ -83,7 +131,9 @@ public function store(StoreSystemUserRequest $request): JsonResponse } /** - * Display the specified resource. + * Show: Retorna os detalhes de um usuário do sistema. + * + * @group Usuários */ public function show(SystemUser $user): JsonResponse { @@ -92,12 +142,14 @@ public function show(SystemUser $user): JsonResponse return response()->json([ 'sucess' => true, - 'data' => $user->load(['creator', 'lastEditor']), + 'data' => $user->load(['creator', 'updater']), ]); } /** - * Update the specified resource in storage. + * update: Atualiza os dados de um usuário do sistema. + * + * @group Usuários */ public function update(UpdateSystemUserRequest $request, SystemUser $user): JsonResponse { @@ -112,14 +164,14 @@ public function update(UpdateSystemUserRequest $request, SystemUser $user): Json ], 422); } - $validated['ultimo_editor'] = auth()->id(); + $validated['updater'] = auth()->id(); $user->update($validated); return response()->json([ 'success' => true, 'message' => 'Usuário atualizado com sucesso', - 'data' => $user->fresh()->load(['creator', 'lastEditor']), + 'data' => $user->fresh()->load(['creator', 'updater']), ]); } catch (\Exception $e) { @@ -131,14 +183,19 @@ public function update(UpdateSystemUserRequest $request, SystemUser $user): Json } } + /** + * updatePassword: Atualiza a senha de um usuário do sistema. + * + * @group Usuários + */ public function updatePassword(UpdateSystemUserPassword $request, SystemUser $user): JsonResponse { - $this->authorize('update', $user); + $this->authorize('updatePassword', $user); try { $user->update([ 'password' => bcrypt($request->input('password')), - 'ultimo_editor' => auth()->id(), + 'updater' => auth()->id(), ]); return response()->json([ @@ -156,7 +213,9 @@ public function updatePassword(UpdateSystemUserPassword $request, SystemUser $us } /** - * Remove the specified resource from storage. + * Destroy: Remove um usuário do sistema. + * + * @group Usuários */ public function destroy(SystemUser $user) { @@ -180,10 +239,16 @@ public function destroy(SystemUser $user) } } + + /** + * changeStatus: Altera o status de um usuário do sistema. + * + * @group Usuários + */ public function changeStatus(Request $request, SystemUser $user): JsonResponse { $request->validate([ - 'status' => 'required|in:Ativo,Inativo,Bloqueado', + 'status' => 'required|in:active,inactive,blocked', ]); try { diff --git a/app/Http/Requests/ChangeStatusSystemUser.php b/app/Http/Requests/ChangeStatusSystemUser.php new file mode 100644 index 0000000..86bb2d0 --- /dev/null +++ b/app/Http/Requests/ChangeStatusSystemUser.php @@ -0,0 +1,28 @@ +check(); + } + + public function rules(): array + { + return [ + 'status' => 'required|in:inactive,active,banned,pending', + ]; + } + + public function messages(): array + { + return [ + 'status.required' => 'O campo status é obrigatório.', + 'status.in' => 'O status deve ser um dos seguintes valores: inactive, active, banned, pending.', + ]; + } +} diff --git a/app/Http/Requests/RegisterUserRequest.php b/app/Http/Requests/RegisterUserRequest.php index d873e98..069b3f6 100644 --- a/app/Http/Requests/RegisterUserRequest.php +++ b/app/Http/Requests/RegisterUserRequest.php @@ -22,10 +22,10 @@ public function authorize(): bool public function rules(): array { return [ - 'nome' => 'required|string', + 'name' => 'required|string', 'email' => 'required|email|unique:system_users,email', 'password' => 'required|string|min:8|confirmed', - 'tipo' => 'required|in:Aluno,Professor', + 'role' => 'required|in:student,teacher', ]; } diff --git a/app/Http/Requests/StoreContent.php b/app/Http/Requests/StoreContent.php index 99a002e..109b38d 100644 --- a/app/Http/Requests/StoreContent.php +++ b/app/Http/Requests/StoreContent.php @@ -15,7 +15,7 @@ public function rules(): array { return [ 'title' => 'required|string|max:255', - 'content' => 'required|string', + 'body' => 'required|string', 'content_type' => 'required|string|max:255', 'content_type_description' => 'nullable|string', 'content_tags' => 'required|array', diff --git a/app/Http/Requests/StoreSystemUserRequest.php b/app/Http/Requests/StoreSystemUserRequest.php index 8fd71c7..2fc1420 100755 --- a/app/Http/Requests/StoreSystemUserRequest.php +++ b/app/Http/Requests/StoreSystemUserRequest.php @@ -1,32 +1,41 @@ check(); } - /** - * Get the validation rules that apply to the request. - * - * @return array|string> - */ public function rules(): array { return [ - 'nome' => 'required|string|max:255', - 'email' => 'required|email|max:100|unique:system_users,email', + 'name' => 'required|string|max:255', + 'email' => 'required|email|unique:system_users,email', 'password' => 'required|string|min:8|confirmed', - 'tipo' => 'required|in:Professor,Aluno,ADM,Moderador,Operador', - 'status' => 'sometimes|in:Ativo,Inativo,Bloqueado', + 'role' => 'required|in:teacher,student,admin,moderator,operator', + ]; + } + + public function messages(): array + { + return [ + 'name.required' => 'O campo nome é obrigatório.', + 'name.string' => 'O campo nome deve ser uma string.', + 'name.max' => 'O campo nome não pode exceder 255 caracteres.', + 'email.required' => 'O campo email é obrigatório.', + 'email.email' => 'O campo email deve ser um endereço de email válido.', + 'email.unique' => 'O email informado já está em uso.', + 'password.required' => 'O campo senha é obrigatório.', + 'password.string' => 'O campo senha deve ser uma string.', + 'password.min' => 'O campo senha deve ter no mínimo 8 caracteres.', + 'password.confirmed' => 'A confirmação da senha não corresponde.', + 'role.required' => 'O campo função é obrigatório.', + 'role.in' => 'A função deve ser uma das seguintes: teacher, student, admin, moderator, operator.', ]; } } diff --git a/app/Http/Requests/UpdateSystemUserPassword.php b/app/Http/Requests/UpdateSystemUserPassword.php index 6131e55..f1bb6ce 100644 --- a/app/Http/Requests/UpdateSystemUserPassword.php +++ b/app/Http/Requests/UpdateSystemUserPassword.php @@ -25,4 +25,14 @@ public function rules(): array 'password' => 'required|string|min:8|confirmed', ]; } + + public function messages(): array + { + return [ + 'password.required' => 'O campo senha é obrigatório.', + 'password.string' => 'O campo senha deve ser uma string.', + 'password.min' => 'O campo senha deve ter no mínimo 8 caracteres.', + 'password.confirmed' => 'A confirmação da senha não corresponde.', + ]; + } } diff --git a/app/Http/Requests/UpdateSystemUserRequest.php b/app/Http/Requests/UpdateSystemUserRequest.php index b5fefda..ee9b5fe 100755 --- a/app/Http/Requests/UpdateSystemUserRequest.php +++ b/app/Http/Requests/UpdateSystemUserRequest.php @@ -30,11 +30,25 @@ public function rules(): array 'sometimes', 'required', 'email', - 'max:100', Rule::unique('system_users')->ignore($userId), ], 'tipo' => 'sometimes|required|in:Professor,Aluno,ADM,Moderador,Operador', 'status' => 'sometimes|in:Ativo,Inativo,Bloqueado', ]; } + + public function messages(): array + { + return [ + 'nome.required' => 'O campo nome é obrigatório.', + 'nome.string' => 'O campo nome deve ser uma string.', + 'nome.max' => 'O campo nome não pode exceder 255 caracteres.', + 'email.required' => 'O campo email é obrigatório.', + 'email.email' => 'O campo email deve ser um endereço de email válido.', + 'email.unique' => 'O email informado já está em uso.', + 'tipo.required' => 'O campo tipo é obrigatório.', + 'tipo.in' => 'O tipo deve ser uma das seguintes opções: Professor, Aluno, ADM, Moderador, Operador.', + 'status.in' => 'O status deve ser uma das seguintes opções: Ativo, Inativo, Bloqueado.', + ]; + } } diff --git a/app/Models/Content.php b/app/Models/Content.php index 1122102..08bf6c3 100644 --- a/app/Models/Content.php +++ b/app/Models/Content.php @@ -14,21 +14,26 @@ class Content extends Model protected $fillable = [ 'title', - 'content', - 'criador', + 'body', + 'created_by', + 'updated_by', 'image_id', 'content_types_id', 'content_tags_id', 'status', 'id_materia', - 'ultimo_editor', 'content_tags_id', 'content_types_id', + 'published_at', + 'duration_minutes', + 'deleted_at', ]; protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', + 'published_at' => 'datetime', + 'deleted_at' => 'datetime', ]; public function contentType() @@ -50,12 +55,12 @@ public function images() public function creator() { - return $this->belongsTo(SystemUser::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by'); } - public function lastEditor() + public function updater() { - return $this->belongsTo(SystemUser::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by'); } public function scopeStatus($query, string $status) diff --git a/app/Models/ContentTag.php b/app/Models/ContentTag.php index 3448e94..ca4491a 100644 --- a/app/Models/ContentTag.php +++ b/app/Models/ContentTag.php @@ -16,9 +16,10 @@ class ContentTag extends Model 'tag_name', 'is_moderator_only', 'count', - 'criador', + 'slug', 'description', - 'ultimo_editor', + 'created_by', + 'updated_by', 'status', ]; @@ -29,11 +30,11 @@ public function contents() public function creator() { - return $this->belongsTo(SystemUser::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by'); } public function lastEditor() { - return $this->belongsTo(SystemUser::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by'); } } diff --git a/app/Models/ContentType.php b/app/Models/ContentType.php index 1336b6e..87df4af 100644 --- a/app/Models/ContentType.php +++ b/app/Models/ContentType.php @@ -15,9 +15,9 @@ class ContentType extends Model protected $fillable = [ 'title', 'description', - 'criador', + 'created_by', 'status', - 'ultimo_editor', + 'updated_by', ]; public function content() @@ -27,11 +27,11 @@ public function content() public function creator() { - return $this->belongsTo(SystemUser::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by'); } public function lastEditor() { - return $this->belongsTo(SystemUser::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by'); } } diff --git a/app/Models/Materias.php b/app/Models/Materias.php index ecfdd76..eb8f204 100755 --- a/app/Models/Materias.php +++ b/app/Models/Materias.php @@ -15,9 +15,9 @@ class Materias extends Model protected $fillable = [ 'nome', 'descricao', - 'criador', + 'created_by', 'status', - 'ultimo_editor', + 'updated_by', ]; protected $casts = [ @@ -27,11 +27,11 @@ class Materias extends Model public function creator() { - return $this->belongsTo(SystemUser::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by'); } public function lastEditor() { - return $this->belongsTo(SystemUser::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by'); } } diff --git a/app/Models/Question.php b/app/Models/Question.php index 385ed0a..0ac228d 100644 --- a/app/Models/Question.php +++ b/app/Models/Question.php @@ -42,15 +42,15 @@ public function materia(): BelongsTo public function creator(): BelongsTo { - return $this->belongsTo(SystemUser::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by'); } public function lastEditor(): BelongsTo { - return $this->belongsTo(SystemUser::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by'); } - public function studentAnswers(): HasMany + public function studentAnswers(): HasMany { return $this->hasMany(StudentAnswer::class); } diff --git a/app/Models/SystemUser.php b/app/Models/SystemUser.php index e9ed669..43447e0 100755 --- a/app/Models/SystemUser.php +++ b/app/Models/SystemUser.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Concerns\HasUlids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -9,18 +10,19 @@ class SystemUser extends Authenticatable { - use HasApiTokens, HasFactory, Notifiable; + use HasApiTokens, HasFactory, Notifiable, HasUlids; protected $table = 'system_users'; protected $fillable = [ - 'nome', + 'name', 'email', 'password', - 'tipo', - 'criador', - 'ultimo_editor', + 'role', + 'created_by', + 'updated_by', 'status', + 'deleted_at', ]; protected $hidden = [ @@ -30,8 +32,55 @@ class SystemUser extends Authenticatable protected $casts = [ 'created_at' => 'datetime', 'updated_at' => 'datetime', + 'deleted_at' => 'datetime', ]; + public function scopeName($query, $name) + { + return $query->whereFullText('name', $name); + } + + public function scopeEmail($query, $email) + { + return $query->whereFullText('email', $email); + } + + public function scopeRole($query, $role) + { + return $query->where('role', $role); + } + + public function scopeStatus($query, $status) + { + return $query->where('status', $status); + } + + public function scopeCreatedAt($query, $date) + { + return $query->whereDate('created_at', $date); + } + + public function scopeUpdatedAt($query, $date) + { + return $query->whereDate('updated_at', $date); + } + + public function scopeDeletedAt($query, $date) + { + return $query->whereDate('deleted_at', $date); + } + + public function scopeCreatedBy($query, $userId) + { + return $query->where('created_by', $userId); + } + + public function scopeUpdatedBy($query, $userId) + { + return $query->where('updated_by', $userId); + } + + // Existing methods public function findForPassport($username) { return $this->where('email', $username)->first(); @@ -39,12 +88,12 @@ public function findForPassport($username) public function creator() { - return $this->belongsTo(self::class, 'criador'); + return $this->belongsTo(SystemUser::class, 'created_by')->withTrashed(); } - public function lastEditor() + public function updater() { - return $this->belongsTo(self::class, 'ultimo_editor'); + return $this->belongsTo(SystemUser::class, 'updated_by')->withTrashed(); } public function generateToken() diff --git a/app/Policies/ContentPolicy.php b/app/Policies/ContentPolicy.php index 8990c98..fce4e60 100644 --- a/app/Policies/ContentPolicy.php +++ b/app/Policies/ContentPolicy.php @@ -28,7 +28,7 @@ public function view(?SystemUser $systemUser, Content $content): bool */ public function create(SystemUser $systemUser): bool { - return in_array($systemUser->tipo, ['ADM', 'Moderador', 'Operador']); + return in_array($systemUser->tipo, ['admin', 'moderator', 'operator']); } /** @@ -36,7 +36,7 @@ public function create(SystemUser $systemUser): bool */ public function update(SystemUser $systemUser, Content $content): bool { - return in_array($systemUser->tipo, ['ADM', 'Moderador', 'Operador']); + return in_array($systemUser->tipo, ['admin', 'moderator', 'operator']); } /** @@ -44,7 +44,7 @@ public function update(SystemUser $systemUser, Content $content): bool */ public function delete(SystemUser $systemUser, Content $content): bool { - return $systemUser->tipo === 'ADM'; + return $systemUser->tipo === 'admin'; } /** @@ -60,11 +60,11 @@ public function restore(SystemUser $systemUser, Content $content): bool */ public function forceDelete(SystemUser $systemUser, Content $content): bool { - return $systemUser->tipo === 'ADM'; + return $systemUser->tipo === 'admin'; } public function changeStatus(SystemUser $systemUser, Content $content): bool { - return in_array($systemUser->tipo, ['ADM', 'Moderador']); + return in_array($systemUser->tipo, ['admin', 'moderator']); } } diff --git a/app/Policies/SystemUserPolicy.php b/app/Policies/SystemUserPolicy.php index b43b1bf..c0ec88b 100755 --- a/app/Policies/SystemUserPolicy.php +++ b/app/Policies/SystemUserPolicy.php @@ -1,25 +1,44 @@ tipo === 'ADM'; + return $user->tipo === 'admin'; } /** - * Determine whether the user can view the model. + * Determina se o usuário pode visualizar um usuário específico. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário a ser visualizado. + * @return bool Retorna `true` se o usuário for administrador ou se estiver visualizando seu próprio registro. */ public function view(SystemUser $user, SystemUser $systemUser): bool { - if ($user->tipo === 'ADM') { + if ($user->tipo === 'admin') { return true; } @@ -27,20 +46,42 @@ public function view(SystemUser $user, SystemUser $systemUser): bool } /** - * Determine whether the user can create models. + * Determina se o usuário pode criar novos usuários. + * + * @param SystemUser $user Usuário autenticado. + * @return bool Retorna `true` se o usuário for administrador. */ public function create(SystemUser $user): bool { - return $user->tipo === 'ADM'; + return $user->tipo === 'admin'; } /** - * Determine whether the user can update the model. + * Determina se o usuário pode atualizar um usuário específico. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário a ser atualizado. + * @return bool Retorna `true` se o usuário for administrador ou se estiver atualizando seu próprio registro. */ public function update(SystemUser $user, SystemUser $systemUser): bool { + if ($user->tipo === 'admin') { + return true; + } - if ($user->tipo === 'ADM') { + return $user->id === $systemUser->id; + } + + /** + * Determina se o usuário pode atualizar a senha de um usuário específico. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário cuja senha será atualizada. + * @return bool Retorna `true` se o usuário for administrador ou se estiver atualizando sua própria senha. + */ + public function updatePassword(SystemUser $user, SystemUser $systemUser): bool + { + if ($user->tipo === 'admin') { return true; } @@ -48,11 +89,15 @@ public function update(SystemUser $user, SystemUser $systemUser): bool } /** - * Determine whether the user can delete the model. + * Determina se o usuário pode excluir um usuário específico. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário a ser excluído. + * @return bool Retorna `true` se o usuário for administrador ou se estiver excluindo seu próprio registro. */ public function delete(SystemUser $user, SystemUser $systemUser): bool { - if ($user->tipo === 'ADM') { + if ($user->tipo === 'admin') { return true; } @@ -60,7 +105,11 @@ public function delete(SystemUser $user, SystemUser $systemUser): bool } /** - * Determine whether the user can restore the model. + * Determina se o usuário pode restaurar um usuário excluído. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário a ser restaurado. + * @return bool Retorna `false` (não permitido). */ public function restore(SystemUser $user, SystemUser $systemUser): bool { @@ -68,11 +117,15 @@ public function restore(SystemUser $user, SystemUser $systemUser): bool } /** - * Determine whether the user can permanently delete the model. + * Determina se o usuário pode excluir permanentemente um usuário. + * + * @param SystemUser $user Usuário autenticado. + * @param SystemUser $systemUser Usuário a ser excluído permanentemente. + * @return bool Retorna `true` se o usuário for administrador ou se estiver excluindo permanentemente seu próprio registro. */ public function forceDelete(SystemUser $user, SystemUser $systemUser): bool { - if ($user->tipo === 'ADM') { + if ($user->tipo === 'admin') { return true; } diff --git a/database/factories/AlternativeFactory.php b/database/factories/AlternativeFactory.php index 7374e8d..bd7b003 100644 --- a/database/factories/AlternativeFactory.php +++ b/database/factories/AlternativeFactory.php @@ -21,8 +21,8 @@ public function definition(): array 'question_id' => Question::factory(), 'content' => $this->faker->sentence(), 'correct' => $this->faker->boolean(), - 'criador' => \App\Models\SystemUser::factory()->create()->id, - 'ultimo_editor' => \App\Models\SystemUser::factory()->create()->id, + 'created_by' => \App\Models\SystemUser::factory()->create()->id, + 'updated_by' => \App\Models\SystemUser::factory()->create()->id, ]; } } diff --git a/database/factories/ContentFactory.php b/database/factories/ContentFactory.php index 89d6733..e69ab03 100644 --- a/database/factories/ContentFactory.php +++ b/database/factories/ContentFactory.php @@ -19,13 +19,13 @@ class ContentFactory extends Factory public function definition(): array { - $status = ['Ativo', 'Inativo', 'Rascunho']; + $status = ['draft', 'inactive', 'archived', 'published', 'active']; return [ 'title' => $this->faker->sentence(), - 'content' => $this->faker->paragraph(), - 'criador' => \App\Models\SystemUser::factory()->create()->id, - 'ultimo_editor' => \App\Models\SystemUser::factory()->create()->id, + 'body' => $this->faker->paragraph(), + 'created_by' => \App\Models\SystemUser::factory()->create()->id, + 'updated_by' => \App\Models\SystemUser::factory()->create()->id, 'status' => $this->faker->randomElement($status), 'content_types_id' => \App\Models\ContentType::factory()->create()->id, ]; diff --git a/database/factories/ContentTagFactory.php b/database/factories/ContentTagFactory.php index fb555f0..6bcb725 100644 --- a/database/factories/ContentTagFactory.php +++ b/database/factories/ContentTagFactory.php @@ -17,13 +17,13 @@ class ContentTagFactory extends Factory public function definition(): array { - $statuses = ['Ativo', 'Inativo']; + $statuses = ['active', 'inactive']; return [ 'tag_name' => $this->faker->word(), 'description' => $this->faker->sentence(), - 'criador' => \App\Models\SystemUser::factory()->create()->id, - 'ultimo_editor' => \App\Models\SystemUser::factory()->create()->id, + 'created_by' => \App\Models\SystemUser::factory()->create()->id, + 'updated_by' => \App\Models\SystemUser::factory()->create()->id, 'is_moderator_only' => $this->faker->boolean(), 'count' => $this->faker->randomNumber(), 'status' => $this->faker->randomElement($statuses), diff --git a/database/factories/ContentTypeFactory.php b/database/factories/ContentTypeFactory.php index 64aaba6..1e53329 100644 --- a/database/factories/ContentTypeFactory.php +++ b/database/factories/ContentTypeFactory.php @@ -17,13 +17,13 @@ class ContentTypeFactory extends Factory public function definition(): array { - $statuses = ['Ativo', 'Inativo']; + $statuses = ['active', 'inactive']; return [ 'title' => $this->faker->name(), 'description' => $this->faker->sentence(), - 'criador' => \App\Models\SystemUser::factory()->create()->id, - 'ultimo_editor' => \App\Models\SystemUser::factory()->create()->id, + 'created_by' => \App\Models\SystemUser::factory()->create()->id, + 'updated_by' => \App\Models\SystemUser::factory()->create()->id, 'status' => $this->faker->randomElement($statuses), ]; } diff --git a/database/factories/MateriasFactory.php b/database/factories/MateriasFactory.php index eef2e6e..50d5087 100755 --- a/database/factories/MateriasFactory.php +++ b/database/factories/MateriasFactory.php @@ -22,8 +22,8 @@ public function definition(): array 'nome' => $this->faker->name(), 'descricao' => $this->faker->sentence(), 'status' => $this->faker->randomElement($status), - 'criador' => \App\Models\SystemUser::factory()->create()->id, - 'ultimo_editor' => \App\Models\SystemUser::factory()->create()->id, + 'created_by' => \App\Models\SystemUser::factory()->create()->id, + 'updated_by' => \App\Models\SystemUser::factory()->create()->id, ]; } } diff --git a/database/factories/QuestionCollectionFactory.php b/database/factories/QuestionCollectionFactory.php index 332a020..2c72e54 100644 --- a/database/factories/QuestionCollectionFactory.php +++ b/database/factories/QuestionCollectionFactory.php @@ -42,7 +42,7 @@ public function withQuestions(int $count = 5): self ->count($count) ->state(function () use ($collection) { return [ - 'materia' => $collection->subject_id, + 'materia_id' => $collection->subject_id, ]; }) ->withAlternatives(4) diff --git a/database/factories/QuestionFactory.php b/database/factories/QuestionFactory.php index 5fe3a9c..bb5e45f 100644 --- a/database/factories/QuestionFactory.php +++ b/database/factories/QuestionFactory.php @@ -26,9 +26,9 @@ public function definition(): array 'title' => $this->faker->sentence(), 'content' => $this->faker->paragraph(), 'correction' => $this->faker->paragraph(), - 'materia' => Materias::factory(), - 'ultimo_editor' => SystemUser::factory()->create()->id, - 'criador' => SystemUser::factory()->create()->id, + 'materia_id' => Materias::factory(), + 'updated_by' => SystemUser::factory()->create()->id, + 'created_by' => SystemUser::factory()->create()->id, 'type' => $this->faker->randomElement($types), 'status' => $this->faker->randomElement($status), ]; diff --git a/database/factories/SystemUserFactory.php b/database/factories/SystemUserFactory.php index 6588793..2146129 100755 --- a/database/factories/SystemUserFactory.php +++ b/database/factories/SystemUserFactory.php @@ -16,14 +16,14 @@ class SystemUserFactory extends Factory */ public function definition(): array { - $types = ['Professor', 'Aluno', 'ADM', 'Moderador', 'Operador']; - $statuses = ['Ativo', 'Inativo', 'Bloqueado']; + $types = ['teacher', 'student', 'admin', 'moderator', 'operator']; + $statuses = ['active', 'inactive', 'banned']; return [ - 'nome' => $this->faker->name(), + 'name' => $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), 'password' => bcrypt('password'), - 'tipo' => $this->faker->randomElement($types), + 'role' => $this->faker->randomElement($types), 'status' => $this->faker->randomElement($statuses), ]; } diff --git a/database/migrations/2025_09_23_123300_create_system_users_table.php b/database/migrations/2025_09_23_123300_create_system_users_table.php index 47ae886..0c26ee7 100755 --- a/database/migrations/2025_09_23_123300_create_system_users_table.php +++ b/database/migrations/2025_09_23_123300_create_system_users_table.php @@ -12,18 +12,27 @@ public function up(): void { Schema::create('system_users', function (Blueprint $table) { - $table->id(); - $table->string('nome', 255); - $table->string('email', 100)->unique(); + $table->ulid('id')->primary(); + $table->string('name', 255); + $table->string('email', 255)->unique(); $table->string('password', 255); - $table->enum('tipo', ['Professor', 'Aluno', 'ADM', 'Moderador', 'Operador'])->default('Aluno'); - $table->unsignedBigInteger('criador')->nullable(); - $table->unsignedBigInteger('ultimo_editor')->nullable(); - $table->enum('status', ['Ativo', 'Inativo', 'Bloqueado'])->default('Ativo'); + $table->enum('role', ['teacher', 'student', 'admin', 'moderator', 'operator'])->default('student'); + $table->ulid('created_by')->nullable(); + $table->ulid('updated_by')->nullable(); + $table->enum('status', ['active', 'inactive', 'banned', 'pending'])->default('active'); + $table->softDeletes(); + $table->timestamps(); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('set null'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('set null'); + $table->fullText('name'); + $table->index('created_at'); + $table->index('updated_at'); + $table->index('deleted_at'); + $table->fullText('email'); + $table->index('status'); + + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('set null'); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('set null'); }); } diff --git a/database/migrations/2025_09_23_123305_create_content_types_table.php b/database/migrations/2025_09_23_123305_create_content_types_table.php index bc1a8d7..d27a584 100644 --- a/database/migrations/2025_09_23_123305_create_content_types_table.php +++ b/database/migrations/2025_09_23_123305_create_content_types_table.php @@ -16,13 +16,22 @@ public function up(): void $table->string('title', 255)->unique(); $table->string('description'); - $table->foreignId('criador') - ->constrained('system_users') + $table->enum('status', ['active', 'inactive'])->default('active'); + $table->string('slug')->nullable(); + $table->longText('icon')->nullable(); + $table->string('color', 50)->nullable(); + + $table->ulid('created_by'); + $table->foreign('created_by') + ->references('id') + ->on('system_users') ->cascadeOnDelete(); - $table->foreignId('ultimo_editor') - ->nullable() - ->constrained('system_users') + $table->ulid('updated_by') + ->nullable(); + $table->foreign('updated_by') + ->references('id') + ->on('system_users') ->nullOnDelete(); $table->timestamps(); @@ -34,6 +43,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('_content_type'); + Schema::dropIfExists('content_types'); } }; diff --git a/database/migrations/2025_09_23_123310_create_materias_table.php b/database/migrations/2025_09_23_123310_create_materias_table.php index 996c743..5e4c4b2 100755 --- a/database/migrations/2025_09_23_123310_create_materias_table.php +++ b/database/migrations/2025_09_23_123310_create_materias_table.php @@ -15,13 +15,15 @@ public function up(): void $table->id(); $table->string('nome', 255)->unique(); $table->string('descricao'); - $table->unsignedBigInteger('criador'); $table->enum('status', ['Ativo', 'Inativo'])->default('Ativo'); - $table->unsignedBigInteger('ultimo_editor')->nullable(); $table->timestamps(); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('set null'); + $table->ulid('created_by'); + + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('cascade'); + + $table->ulid('updated_by')->nullable(); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('set null'); }); } diff --git a/database/migrations/2025_09_23_123312_create_content_tags_table.php b/database/migrations/2025_09_23_123312_create_content_tags_table.php index daa255c..f3554b9 100644 --- a/database/migrations/2025_09_23_123312_create_content_tags_table.php +++ b/database/migrations/2025_09_23_123312_create_content_tags_table.php @@ -1,5 +1,4 @@ boolean('is_moderator_only')->default(false); $table->integer('count')->default(0); $table->string('description', 255); - $table->foreignId('criador') - ->constrained('system_users') + $table->string('slug', 50)->nullable(); + $table->string('color', 50)->nullable(); + $table->enum('status', ['active', 'inactive'])->default('active'); + + $table->softDeletes(); + + $table->ulid('created_by'); + $table->foreign('created_by') + ->references('id') + ->on('system_users') ->cascadeOnDelete(); - $table->foreignId('ultimo_editor') - ->nullable() - ->constrained('system_users') + $table->ulid('updated_by')->nullable(); + $table->foreign('updated_by') + ->references('id') + ->on('system_users') ->nullOnDelete(); + $table->timestamps(); }); } diff --git a/database/migrations/2025_09_23_123320_create_content_table.php b/database/migrations/2025_09_23_123320_create_content_table.php index 7dc6113..36bf896 100755 --- a/database/migrations/2025_09_23_123320_create_content_table.php +++ b/database/migrations/2025_09_23_123320_create_content_table.php @@ -14,7 +14,8 @@ public function up(): void Schema::create('contents', function (Blueprint $table) { $table->id(); $table->string('title', 255); - $table->longText('content'); + $table->longText('body'); + $table->integer('duration_minutes')->nullable(); $table->foreignId('id_materia') ->nullable() @@ -25,20 +26,34 @@ public function up(): void ->constrained('content_types') ->restrictOnDelete(); - $table->foreignId('criador') - ->constrained('system_users') + $table->ulid('created_by'); + $table->foreign('created_by') + ->references('id') + ->on('system_users') ->cascadeOnDelete(); - $table->foreignId('ultimo_editor') - ->nullable() - ->constrained('system_users') + $table->ulid('updated_by')->nullable(); + $table->foreign('updated_by') + ->references('id') + ->on('system_users') ->nullOnDelete(); $table->foreignId('content_tags_id') ->constrained('content_tags') ->restrictOnDelete(); - $table->enum('status', ['Ativo', 'Inativo', 'Rascunho'])->default('Ativo'); + $table->enum('status', ['draft', 'inactive', 'archived', 'published', 'active'])->default('draft'); + + $table->index('status'); + $table->index('published_at'); + $table->index('created_by'); + $table->index('updated_by'); + $table->index('deleted_at'); + $table->fullText(['title', 'body']); + $table->index('content_tags_id'); + $table->index('content_types_id'); + + $table->softDeletes(); $table->timestamp('published_at')->nullable(); $table->timestamps(); }); diff --git a/database/migrations/2025_09_23_165457_create_questoes_table.php b/database/migrations/2025_09_23_165457_create_questoes_table.php index b442142..ab528ad 100755 --- a/database/migrations/2025_09_23_165457_create_questoes_table.php +++ b/database/migrations/2025_09_23_165457_create_questoes_table.php @@ -16,15 +16,15 @@ public function up(): void $table->string('title'); $table->longText('content'); $table->longText('correction'); - $table->unsignedBigInteger('materia'); - $table->unsignedBigInteger('ultimo_editor')->nullable(); - $table->unsignedBigInteger('criador'); + $table->unsignedBigInteger('materia_id'); + $table->ulid('created_by'); + $table->ulid('updated_by')->nullable(); $table->enum('type', ['Multipla', 'VerdadeiroFalso', 'Aberta'])->default('Multipla'); $table->enum('status', ['Active', 'Inactive'])->default('Active'); $table->timestamps(); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('set null'); + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('set null'); }); } @@ -33,6 +33,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('questoes'); + Schema::dropIfExists('questions'); } }; diff --git a/database/migrations/2025_09_23_170149_create_alternativas_table.php b/database/migrations/2025_09_23_170149_create_alternativas_table.php index 985f331..d7c881d 100755 --- a/database/migrations/2025_09_23_170149_create_alternativas_table.php +++ b/database/migrations/2025_09_23_170149_create_alternativas_table.php @@ -16,13 +16,13 @@ public function up(): void $table->unsignedBigInteger('question_id'); $table->string('content', 255); $table->boolean('correct'); - $table->unsignedBigInteger('criador'); - $table->unsignedBigInteger('ultimo_editor'); + $table->ulid('created_by'); + $table->ulid('updated_by')->nullable(); $table->timestamps(); $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade'); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('cascade'); }); } diff --git a/database/migrations/2025_09_23_170416_create_turmas_table.php b/database/migrations/2025_09_23_170416_create_turmas_table.php index fdb397f..02348c5 100755 --- a/database/migrations/2025_09_23_170416_create_turmas_table.php +++ b/database/migrations/2025_09_23_170416_create_turmas_table.php @@ -16,14 +16,14 @@ public function up(): void $table->string('nome', 255); $table->integer('limite'); $table->enum('status', ['Ativo', 'Inativo'])->default('Ativo'); - $table->unsignedBigInteger('responsavel'); - $table->unsignedBigInteger('criador'); - $table->unsignedBigInteger('ultimo_editor'); + $table->ulid('responsavel'); + $table->ulid('created_by'); + $table->ulid('updated_by'); $table->timestamps(); $table->foreign('responsavel')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('cascade'); }); } diff --git a/database/migrations/2025_09_23_170916_create_turma_alunos_table.php b/database/migrations/2025_09_23_170916_create_turma_alunos_table.php index 0b3cd65..fe4be4f 100755 --- a/database/migrations/2025_09_23_170916_create_turma_alunos_table.php +++ b/database/migrations/2025_09_23_170916_create_turma_alunos_table.php @@ -14,16 +14,16 @@ public function up(): void Schema::create('turma_alunos', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('id_turma'); - $table->unsignedBigInteger('id_aluno'); - $table->unsignedBigInteger('criador'); - $table->unsignedBigInteger('ultimo_editor'); + $table->ulid('id_aluno'); + $table->ulid('created_by'); + $table->ulid('updated_by'); $table->enum('status', ['Ativo', 'Inativo'])->default('Ativo'); $table->timestamps(); $table->foreign('id_turma')->references('id')->on('turmas')->onDelete('cascade'); $table->foreign('id_aluno')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('criador')->references('id')->on('system_users')->onDelete('cascade'); - $table->foreign('ultimo_editor')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('created_by')->references('id')->on('system_users')->onDelete('cascade'); + $table->foreign('updated_by')->references('id')->on('system_users')->onDelete('cascade'); }); } diff --git a/database/migrations/2025_09_23_174312_create_question_colletion_table.php b/database/migrations/2025_09_23_174312_create_question_colletion_table.php index 4f9c342..bf9c052 100755 --- a/database/migrations/2025_09_23_174312_create_question_colletion_table.php +++ b/database/migrations/2025_09_23_174312_create_question_colletion_table.php @@ -18,8 +18,8 @@ public function up(): void $table->unsignedBigInteger('subject_id'); $table->enum('type', ['Exam', 'Simulation', 'Activity', 'Exercise'])->default('Activity'); $table->dateTime('due_date')->nullable(); - $table->unsignedBigInteger('created_by'); - $table->unsignedBigInteger('updated_by'); + $table->ulid('created_by'); + $table->ulid('updated_by')->nullable(); $table->enum('status', ['Active', 'Inactive'])->default('Active'); $table->timestamps(); diff --git a/database/migrations/2025_09_23_174805_create_class_activity_table.php b/database/migrations/2025_09_23_174805_create_class_activity_table.php index f9c7ad6..f74537a 100755 --- a/database/migrations/2025_09_23_174805_create_class_activity_table.php +++ b/database/migrations/2025_09_23_174805_create_class_activity_table.php @@ -15,8 +15,8 @@ public function up(): void $table->id(); $table->unsignedBigInteger('class_id'); $table->unsignedBigInteger('collection_id'); - $table->unsignedBigInteger('created_by'); - $table->unsignedBigInteger('updated_by'); + $table->ulid('created_by'); + $table->ulid('updated_by'); $table->dateTime('assigned_at')->nullable(); $table->dateTime('deadline')->nullable(); $table->enum('status', ['Active', 'Inactive'])->default('Active'); diff --git a/database/migrations/2025_09_23_174906_create_question_activity_table.php b/database/migrations/2025_09_23_174906_create_question_activity_table.php index b2287cf..e1119e6 100755 --- a/database/migrations/2025_09_23_174906_create_question_activity_table.php +++ b/database/migrations/2025_09_23_174906_create_question_activity_table.php @@ -15,8 +15,8 @@ public function up(): void $table->id(); $table->unsignedBigInteger('collection_id'); $table->unsignedBigInteger('question_id'); - $table->unsignedBigInteger('created_by'); - $table->unsignedBigInteger('updated_by'); + $table->ulid('created_by'); + $table->ulid('updated_by'); $table->enum('status', ['Active', 'Inactive'])->default('Active'); $table->integer('order')->nullable()->comment('Question order within collection'); $table->timestamps(); diff --git a/database/migrations/2025_10_27_203346_add_status_to_content_types_table.php b/database/migrations/2025_10_27_203346_add_status_to_content_types_table.php deleted file mode 100644 index a5ab344..0000000 --- a/database/migrations/2025_10_27_203346_add_status_to_content_types_table.php +++ /dev/null @@ -1,28 +0,0 @@ -enum('status', ['Ativo', 'Inativo'])->default('Ativo'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('content_types', function (Blueprint $table) { - $table->dropColumn('status'); - }); - } -}; diff --git a/database/migrations/2025_10_27_203624_add_status_to_content_tags_table.php b/database/migrations/2025_10_27_203624_add_status_to_content_tags_table.php deleted file mode 100644 index 19638c6..0000000 --- a/database/migrations/2025_10_27_203624_add_status_to_content_tags_table.php +++ /dev/null @@ -1,28 +0,0 @@ -enum('status', ['Ativo', 'Inativo'])->default('Ativo'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('content_tags', function (Blueprint $table) { - $table->dropColumn('status'); - }); - } -}; diff --git a/database/migrations/2025_11_08_031640_create_student_answers_table.php b/database/migrations/2025_11_08_031640_create_student_answers_table.php index 199f1cf..6699f98 100644 --- a/database/migrations/2025_11_08_031640_create_student_answers_table.php +++ b/database/migrations/2025_11_08_031640_create_student_answers_table.php @@ -13,13 +13,13 @@ public function up(): void { Schema::create('student_answers', function (Blueprint $table) { $table->id(); - $table->unsignedBigInteger('student_id'); + $table->ulid('student_id'); $table->unsignedBigInteger('question_id'); $table->unsignedBigInteger('collection_id')->nullable(); $table->longText('answer')->nullable(); $table->decimal('score', 5, 2)->nullable()->comment('Nota dada pelo professor'); $table->longText('feedback')->nullable()->comment('Feedback do professor'); - $table->unsignedBigInteger('corrected_by')->nullable(); + $table->ulid('corrected_by')->nullable(); $table->dateTime('submitted_at')->nullable(); $table->dateTime('corrected_at')->nullable(); $table->enum('status', ['Pending', 'Submitted', 'Corrected'])->default('Pending'); diff --git a/database/seeders/SystemUserSeeder.php b/database/seeders/SystemUserSeeder.php index 00b9e7a..625a384 100755 --- a/database/seeders/SystemUserSeeder.php +++ b/database/seeders/SystemUserSeeder.php @@ -12,30 +12,30 @@ public function run(): void { SystemUser::create([ - 'nome' => 'Administrador', + 'name' => 'Administrador', 'email' => 'admin@mesominds.com', 'password' => bcrypt('admin123'), - 'tipo' => 'ADM', - 'status' => 'Ativo', - 'criador' => null, + 'role' => 'admin', + 'status' => 'active', + 'created_by' => null, ]); SystemUser::create([ - 'nome' => 'Moderador', + 'name' => 'Moderador', 'email' => 'moderador@mesominds.com', 'password' => bcrypt('mod123'), - 'tipo' => 'Moderador', - 'status' => 'Ativo', - 'criador' => null, + 'role' => 'moderator', + 'status' => 'active', + 'created_by' => null, ]); SystemUser::create([ - 'nome' => 'Operador', + 'name' => 'Operador', 'email' => 'operador@mesominds.com', 'password' => bcrypt('op123'), - 'tipo' => 'Operador', - 'status' => 'Ativo', - 'criador' => null, + 'role' => 'operator', + 'status' => 'active', + 'created_by' => null, ]); SystemUser::factory()->count(5)->create(); diff --git a/resources/views/scribe/index.blade.php b/resources/views/scribe/index.blade.php index a3eeaaa..077456a 100644 --- a/resources/views/scribe/index.blade.php +++ b/resources/views/scribe/index.blade.php @@ -110,27 +110,6 @@
  • POST api/validatetoken -
  • -
  • - PUT api/users/{user_id}/password -
  • -
  • - GET api/users -
  • -
  • - Store a newly created resource in storage. -
  • -
  • - Display the specified resource. -
  • -
  • - Update the specified resource in storage. -
  • -
  • - Remove the specified resource from storage. -
  • -
  • - PATCH api/users/{user_id}/status
  • GET api/materias/filter @@ -242,6 +221,34 @@
  • + @@ -5429,31 +5436,158 @@ -

    PUT api/users/{user_id}/password

    +

    GET api/materias/filter

    - +
    Example request:
    -
    curl --request PUT \
    -    "http://localhost:8000/api/users/1/password" \
    +    
    curl --request GET \
    +    --get "http://localhost:8000/api/materias/filter" \
    +    --header "Content-Type: application/json" \
    +    --header "Accept: application/json"
    + + +
    +
    const url = new URL(
    +    "http://localhost:8000/api/materias/filter"
    +);
    +
    +const headers = {
    +    "Content-Type": "application/json",
    +    "Accept": "application/json",
    +};
    +
    +fetch(url, {
    +    method: "GET",
    +    headers,
    +}).then(response => response.json());
    + +
    + + +
    +

    Example response (401):

    +
    +
    + + Show headers + +
    cache-control: no-cache, private
    +content-type: application/json
    +access-control-allow-origin: *
    + 
    +
    +{
    +    "success": false,
    +    "message": "Não autenticado. Token inválido ou ausente."
    +}
    + 
    +
    + + +
    +

    + Request    + +    + +

    +

    + GET + api/materias/filter +

    +

    Headers

    +
    + Content-Type   +  +   +   + +
    +

    Example: application/json

    +
    +
    + Accept   +  +   +   + +
    +

    Example: application/json

    +
    +
    + +

    PATCH api/materias/{materia_id}/status

    + +

    +

    + + + + +
    Example request:
    + + +
    +
    curl --request PATCH \
    +    "http://localhost:8000/api/materias/1/status" \
         --header "Content-Type: application/json" \
         --header "Accept: application/json" \
         --data "{
    -    \"password\": \"|]|{+-\"
    +    \"status\": \"Inativo\"
     }"
     
    const url = new URL(
    -    "http://localhost:8000/api/users/1/password"
    +    "http://localhost:8000/api/materias/1/status"
     );
     
     const headers = {
    @@ -5462,64 +5596,64 @@
     };
     
     let body = {
    -    "password": "|]|{+-"
    +    "status": "Inativo"
     };
     
     fetch(url, {
    -    method: "PUT",
    +    method: "PATCH",
         headers,
         body: JSON.stringify(body),
     }).then(response => response.json());
    - + -