File manager - Edit - /var/www/html/spdc/api/app/Http/Controllers/OptionController.php
Back
<?php namespace App\Http\Controllers; use App\Models\PlaceType; use App\Models\ScaleTeam; use App\Models\Validation; use Illuminate\Http\Request; use App\Models\ExternalAgent; use App\Models\ScaleFunction; use App\Models\CategoryOption; use App\Models\OccurrencyType; use Illuminate\Http\JsonResponse; use App\Classes\BaseServiceResponse; use App\Http\Services\OptionService; use Illuminate\Support\Facades\Validator; class OptionController extends Controller { private OptionService $optionService; public function __construct() { $this->optionService = new OptionService(); } /** * @OA\Get( * path="/api/option/validations", * summary="Get all validations options", * description="Get all validations options", * operationId="GetAllValidationsOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="List of all validations", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function getValidations(): JsonResponse { return $this->response($this->optionService->getOptions(Validation::class)); } /** * @OA\Get( * path="/api/option/categories", * summary="Get all categories options", * description="Get all categories options", * operationId="GetAllCategoriesOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="List of all categories", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function getCategories(): JsonResponse { return $this->response($this->optionService->getOptions(CategoryOption::class)); } /** * @OA\Get( * path="/api/option/occurrency-types", * summary="Get all occurrency types options", * description="Get all occurrency types options", * operationId="GetAllOccurrencyTypeOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Parameter( * name="with_category", * in="query", * description="Return results with category_id. Value: 1", * required=false, * @OA\Schema(type="string") * ), * @OA\Parameter( * name="category_id", * in="query", * description="Category ID to filter occurrency types that has relation with.", * required=false, * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="List of all occurrency types", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function getOccurrencyTypes(Request $request): JsonResponse { return $this->response($this->optionService->getOptions(OccurrencyType::class, $request)); } /** * @OA\Get( * path="/api/option/scripture-types", * summary="Get all scripture types options", * description="Get all scripture types options", * operationId="GetAllScriptureTypeOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Parameter( * name="category_id", * in="query", * description="Category ID to filter scripture types that has relation with.", * required=false, * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="List of all scripture types", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function getScriptureTypes(): JsonResponse { return $this->response($this->optionService->getScriptureTypesOptions()); } /** * @OA\Get( * path="/api/option/place-types", * summary="Get all place types options", * description="Get all place types options", * operationId="GetAllPlaceTypesOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="List of all place types", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ), * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ), * ), * ) */ public function getPlaceTypes(): JsonResponse { return $this->response($this->optionService->getOptions(PlaceType::class)); } /** * @OA\Get( * path="/api/option/external-agents", * summary="Lista todos os agentes externos", * description="Lista todos os agentes externos", * operationId="GetAllExternalAgentsOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="List of all occurrency types", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function getExternalAgents(Request $request): JsonResponse { return $this->response($this->optionService->getOptions(ExternalAgent::class, $request)); } /** * @OA\Get( * path="/api/option/scale-functions", * summary="Lista todas as opções de funções de escala", * description="Lista todas as opções de funções de escala", * operationId="GetAllScaleFunctionsOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Parameter( * name="type", * in="query", * description="Tipo da função: INTERNA ou EXTERNA.", * required=false, * @OA\Schema(type="string") * ), * @OA\Parameter( * name="enable", * in="query", * description="A função está ativa: 1, 0. Por padrão, será retornado somente as ativas.", * required=false, * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="List of all scale functions", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ), * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ), * ), * ) */ public function getScaleFunctions(Request $request): JsonResponse { return $this->response($this->optionService->getScaleFunctionsOptions($request)); } /** * @OA\Get( * path="/api/option/internal-agents", * summary="Lista todas as opções de agentes internos", * description="Lista todas as opções de agentes internos", * operationId="GetAllInternalAgentsOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Parameter( * name="scale_function_id", * in="query", * description="ID da função de escala que será filtrada.", * required=false, * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="Lista de todos os agentes internos", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Sucesso."), * ), * ), * @OA\Response( * response="401", * description="Não autorizado", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Não autorizado."), * ), * ), * ) */ public function getInternalAgents(Request $request): JsonResponse { $validator = Validator::make($request->all(), [ 'scale_function_id' => ['required', 'exists:scale_functions,id'], 'department_id' => ['required', 'exists:departments,id'] ]); if ($validator->fails()) { return $this->response(new BaseServiceResponse( JsonResponse::HTTP_UNPROCESSABLE_ENTITY, $validator->errors()->toArray(), __('general.validation_error') )); } return $this->response($this->optionService->getInternalAgentsOptions($request)); } /** * @OA\Get( * path="/api/option/scale-teams", * summary="Lista todas as opções de equipes de escala", * description="Lista todas as opções de equipes de escala", * operationId="GetAllScaleTeamsOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="Lista de todas as opções de equipes de escala", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Sucesso."), * ), * ), * @OA\Response( * response="401", * description="Não autorizado", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Não autorizado."), * ), * ), * ) */ public function getScaleTeams(): JsonResponse { return $this->response($this->optionService->getOptions(ScaleTeam::class)); } /** * @OA\Get( * path="/api/option/available-scales", * summary="Lista todas as opções de escalas disponíveis", * description="Lista todas as opções de escalas disponíveis", * operationId="GetAllAvailableScalesOptions", * security={{"bearerAuth":{}}}, * tags={"options"}, * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Sucesso."), * ), * ), * @OA\Response( * response="401", * description="Não autorizado", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Não autorizado."), * ), * ), * ) */ public function getAvailableScales(): JsonResponse { return $this->response($this->optionService->getAvailableScales()); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings