SettingController
class SettingController extends Controller (View source)
Controller responsible for rendering settings pages and their sections.
This controller provides partial HTML views consumed by the settings panel via asynchronous (AJAX) requests. Each section may optionally support server-side searching and returns either a full section view or a list-only partial depending on the request type.
Traits
Trait JsonResponseTrait.
Provides standardized and safe error logging with UTF-8 encoding, sensitive data masking, and controlled stack traces.
Methods
Return a 200 OK JSON response.
Return a 201 Created JSON response.
Return a 202 Accepted JSON response (request accepted for processing).
Return a 205 Reset Content JSON response.
Return a 400 Bad Request JSON response.
Return a 401 Unauthorized JSON response.
Return a 403 Forbidden JSON response.
Return a 404 Not Found JSON response.
Return a 409 Conflict JSON response.
Return a 422 Unprocessable Entity JSON response for validation errors.
Return a 429 Too Many Requests JSON response.
Return a 500 Internal Server Error JSON response.
Logs an error with consistent formatting and context.
Masks common sensitive fields (e.g., passwords, tokens) in the given context array.
Recursively converts all string values to UTF-8.
Returns a string representation of the exception trace, limited to the given number of lines.
Render the main settings container page.
Render the genres settings section.
Render the school classes settings section.
Render the users settings section.
Render the general configuration settings section.
Render the services settings section.
Details
protected JsonResponse
successResponse(array $data = [])
Return a 200 OK JSON response.
protected JsonResponse
createdResponse(array $data = [])
Return a 201 Created JSON response.
protected JsonResponse
acceptedResponse()
Return a 202 Accepted JSON response (request accepted for processing).
protected JsonResponse
noContentResponse()
Return a 204 No Content JSON response.
protected JsonResponse
resetContentResponse()
Return a 205 Reset Content JSON response.
protected JsonResponse
badRequestResponse(array $errors)
Return a 400 Bad Request JSON response.
protected JsonResponse
unauthorizedResponse(string $message = 'Não autorizado.')
Return a 401 Unauthorized JSON response.
protected JsonResponse
forbiddenResponse(string $message = 'Acesso negado.')
Return a 403 Forbidden JSON response.
protected JsonResponse
notFoundResponse(string $message = 'Recurso não encontrado.')
Return a 404 Not Found JSON response.
protected JsonResponse
conflictResponse(array $errors)
Return a 409 Conflict JSON response.
protected JsonResponse
validationErrorResponse(array $errors)
Return a 422 Unprocessable Entity JSON response for validation errors.
protected JsonResponse
tooManyRequestsResponse(string $message = 'Muitas requisições. Tente novamente mais tarde.')
Return a 429 Too Many Requests JSON response.
protected JsonResponse
internalErrorResponse(Throwable $e, string $message = 'Erro interno.')
Return a 500 Internal Server Error JSON response.
Logs the exception and returns a standardized JSON error message.
protected void
logError(string $message, Throwable $exception, array $context = [], string|null $channel = null)
Logs an error with consistent formatting and context.
protected array
sanitizeSensitiveData(array $data)
Masks common sensitive fields (e.g., passwords, tokens) in the given context array.
protected array
encodeStringsUtf8(array $data)
Recursively converts all string values to UTF-8.
protected string
getLimitedTrace(Throwable $exception, int $maxLines = 10)
Returns a string representation of the exception trace, limited to the given number of lines.
View
index()
Render the main settings container page.
This view acts as the shell for all dynamically loaded settings sections (genres, classes, users, config).
View
genres(Request $request)
Render the genres settings section.
Supports optional server-side searching by genre name or color hex value. When the request is made via AJAX, only the genres list partial is returned; otherwise, the full section view is rendered.
View
schoolClasses(Request $request)
Render the school classes settings section.
Supports optional searching by course name. Returns either the full section or a list-only partial when requested via AJAX.
View
users(Request $request)
Render the users settings section.
Supports optional searching by user name or hashed email value. For AJAX requests, only the users list partial is returned to allow dynamic list updates without reloading the entire section.
View
config()
Render the general configuration settings section.
Loads application configuration values stored in the settings table. This section does not support searching or AJAX list updates.
View
services()
Render the services settings section.
Loads application services for download.