From 0ad3f0cf8a42cd88743909ea79421cabc6604972 Mon Sep 17 00:00:00 2001 From: Djonathan Date: Wed, 29 Jun 2022 16:51:29 -0300 Subject: [PATCH] Validation of client code in the user registration. --- app/Helpers/Model/EntityJson.php | 135 ------------ app/Helpers/Model/ModelExtractor.php | 97 --------- app/Helpers/Model/TableExtractor.php | 201 ------------------ .../Model/filter/FieldFilterBuilder.php | 26 --- app/Helpers/Model/filter/FilterBuilder.php | 159 -------------- .../Model/filter/FilterBuilderFactory.php | 15 -- .../Model/filter/FilterBuilderResponse.php | 42 ---- app/Helpers/Model/filter/FilterItem.php | 111 ---------- app/Helpers/Model/filter/FilterType.php | 120 ----------- app/Helpers/Model/filter/IFilterBuilder.php | 15 -- app/Helpers/Model/filter/OrderItem.php | 72 ------- app/Http/Controllers/AboutUsController.php | 1 - app/Http/Controllers/ClientController.php | 2 + .../Controllers/InfoSectorialController.php | 2 + app/Http/Controllers/NewsController.php | 2 + .../Controllers/NotificationController.php | 1 - app/Http/Controllers/PermissionController.php | 2 + app/Http/Controllers/RoleController.php | 2 + app/Http/Controllers/UserController.php | 1 - app/Http/Requests/AzuxRequest.php | 46 ---- app/Http/Requests/ForgotPasswordRequest.php | 2 + app/Http/Requests/LoginResquest.php | 2 + app/Http/Requests/ResetPasswordRequest.php | 2 + app/Http/Requests/StoreAboutUsRequest.php | 4 +- .../Requests/StoreNotificationRequest.php | 2 + app/Http/Requests/StoreUserRequest.php | 11 +- .../Requests/UploadInfoSectorialRequest.php | 4 +- app/Http/Resources/AboutUsResource.php | 11 +- .../Resources/DadosCadastraisResponse.php | 12 +- app/Http/Resources/EconomyResource.php | 12 +- app/Http/Resources/FaqResource.php | 11 +- app/Http/Resources/NewsResource.php | 12 +- app/Http/Resources/NotificationResource.php | 12 +- .../Resources/OperationSummaryResource.php | 12 +- app/Http/Resources/OverviewResource.php | 12 +- app/Http/Resources/PldResource.php | 12 +- app/Http/Resources/TelemetryResource.php | 12 +- app/Http/Resources/UserResource.php | 11 +- app/Interface/RepositoryInterfaces.php | 3 +- app/Models/AboutUs.php | 2 + app/Models/DadosCadastrais.php | 2 + app/Models/DadosTe.php | 2 + app/Models/Economy.php | 2 + app/Models/Faq.php | 2 + app/Models/InfoSectorial.php | 2 + app/Models/Med5min.php | 2 + app/Models/Notifications.php | 2 + app/Models/Parameters.php | 2 + app/Models/Permission.php | 2 + app/Models/Pld.php | 2 + app/Models/Role.php | 2 + app/Models/User.php | 2 + .../AboutUs/AboutUsContractInterface.php | 2 + app/Repositories/ContractInterface.php | 2 + .../DadosCadastraisContractInterface.php | 2 + .../DadosTe/DadosTeContractInterface.php | 2 + .../Economy/EconomyContractInterface.php | 2 + .../Faqs/FaqContractInterface.php | 2 + app/Repositories/Faqs/FaqRepository.php | 2 + .../Med5min/Med5minContractInterface.php | 2 + app/Repositories/MethodsTrait.php | 2 + .../NotificationContractInterface.php | 2 + .../Notifications/NotificationRepository.php | 2 + app/Repositories/Pld/PldContractInterface.php | 2 + app/Repositories/Pld/PldRepository.php | 8 +- app/Rules/Uppercase.php | 45 ++++ .../FilterBuilder/Entity/FilterItem.php | 2 + .../FilterBuilder/Entity/OrderItem.php | 2 + app/Support/FilterBuilder/EntityJson.php | 2 + .../FilterBuilder/FilterQueryBuilder.php | 2 + app/Support/FilterBuilder/FilterType.php | 2 + app/Support/FilterBuilder/FiltersQuery.php | 2 + .../Interfaces/IFilterBuilder.php | 2 + database/factories/AboutUsFactory.php | 15 ++ 74 files changed, 215 insertions(+), 1128 deletions(-) delete mode 100644 app/Helpers/Model/EntityJson.php delete mode 100644 app/Helpers/Model/ModelExtractor.php delete mode 100644 app/Helpers/Model/TableExtractor.php delete mode 100644 app/Helpers/Model/filter/FieldFilterBuilder.php delete mode 100644 app/Helpers/Model/filter/FilterBuilder.php delete mode 100644 app/Helpers/Model/filter/FilterBuilderFactory.php delete mode 100644 app/Helpers/Model/filter/FilterBuilderResponse.php delete mode 100644 app/Helpers/Model/filter/FilterItem.php delete mode 100644 app/Helpers/Model/filter/FilterType.php delete mode 100644 app/Helpers/Model/filter/IFilterBuilder.php delete mode 100644 app/Helpers/Model/filter/OrderItem.php delete mode 100644 app/Http/Requests/AzuxRequest.php create mode 100644 app/Rules/Uppercase.php create mode 100644 database/factories/AboutUsFactory.php diff --git a/app/Helpers/Model/EntityJson.php b/app/Helpers/Model/EntityJson.php deleted file mode 100644 index 2b8ac46..0000000 --- a/app/Helpers/Model/EntityJson.php +++ /dev/null @@ -1,135 +0,0 @@ - $value) { - $this->$key = $value; - } - } - - public function jsonSerialize() - { - $vars = get_object_vars($this); - $obj = new \stdClass(); - foreach ($vars as $key => $value) { - $obj->$key = $value; - } - return $obj; - } - - public function jsonSerializeUpperKey() - { - $vars = get_object_vars($this); - $obj = new \stdClass(); - foreach ($vars as $key => $value) { - $key = strtoupper($key); - $obj->$key = $value; - } - return $obj; - } - - public function jsonSerializeLowerKey() - { - $vars = get_object_vars($this); - $obj = new \stdClass(); - foreach ($vars as $key => $value) { - $key = strtolower($key); - $obj->$key = $value; - } - return $obj; - } - - public function jsonSetObject(\stdClass $jsonData) - { - $vars = get_object_vars($jsonData); - foreach ($vars as $key => $value) { - $method = "set" . ucfirst($key); - if (method_exists($this, $method)) { - $this->$method($value); - } else { - if (property_exists(get_class($this), $key)) { - $this->$key = $value; - } - } - } - } - - public function fill(\stdClass $jsonData) - { - $vars = get_object_vars($jsonData); - foreach ($vars as $key => $value) { - $campo = strtolower($key); - $method = "set" . ucfirst($campo); - if (method_exists($this, $method)) { - $this->$method($value); - } else { - if (property_exists(get_class($this), $campo)) { - $this->$campo = $value; - } - } - } - } - - public function toArray() - { - $vars = get_object_vars($this); - $result = array(); - foreach ($vars as $key => $value) { - $method = "get" . ucfirst($key); - $key = strtoupper($key); - $valor = $value; - if (method_exists($this, $method)) { - $valor = $this->$method(); - } - $result[$key] = $valor; - } - return $result; - } - - /** - * Converte um array de objeto stdClass para uma entidade - * @param $className - * @param array $arrayOfObject - * @return array - */ - protected function arrayObjectCast($className, array $arrayOfObject) : array - { - $arr = []; - if (!empty($arrayOfObject)) { - // verificando o elemento do array - $obj = $arrayOfObject[0]; - // se for um array associativo converte para stdClass - if (is_array($obj) && count(array_filter(array_keys($obj), 'is_string')) > 0) { - $obj = (object) $obj; - } - if (get_class($obj) == "stdClass") { - foreach ($arrayOfObject as $item) { - $e = new $className(); - if (method_exists($e, 'jsonSetObject')) { - $e->jsonSetObject($item); - $arr[] = $e; - } - } - } elseif (get_class($obj) == $className) { - return $arrayOfObject; - } - } - return $arr; - } -} diff --git a/app/Helpers/Model/ModelExtractor.php b/app/Helpers/Model/ModelExtractor.php deleted file mode 100644 index fcf877b..0000000 --- a/app/Helpers/Model/ModelExtractor.php +++ /dev/null @@ -1,97 +0,0 @@ -modelClass = $modelClass; - $this->instanceModel(); - } - - public function getAttributeFromMethod($method, array $parameters = []) - { - if (method_exists($this->model, $method)) { - if (count($parameters) > 0) { - $result = [$this->model, $method](...$parameters); - } else { - $result = [$this->model, $method](); - } - if (isset($result)) { - if ($result instanceof $this->modelClass) { - $this->setAttributeFromDataArray($result->toArray(), $this->model->getCasts()); - return $this->getAttributes(); - } elseif ($result instanceof Collection) { - $this->setAttributeFromCollection($result); - return $this->getAttributes(); - } elseif (is_array($result)) { - $this->setAttributeFromDataArray((array) $result[0], $this->model->getCasts()); - return $this->getAttributes(); - } elseif (is_object($result)) { - $this->setAttributeFromDataArray((array) $result, $this->model->getCasts()); - return $this->getAttributes(); - } else { - throw new \Exception('Nao foi possivel converter esse tipo de retorno verificar '); - } - } - } else { - throw new \Exception('Method not found for this class'); - } - } - - private function setAttributeFromCollection(Collection $collection) - { - $casts = $this->model->getCasts(); - $this->setAttributeFromDataArray($collection->toArray()[0], $casts); - } - - private function setAttributeFromDataArray(array $data, array $casts = []) - { - $attributes = []; - foreach ($data as $key => $value) { - if (!empty($casts) && isset($casts[$key])) { - $attributes[] = $this->createColumn($key, $casts[$key]); - } else { - $attributes[] = $this->createColumn($key, $this->getDataTypeByValue($value)); - } - } - - $this->attributes = $attributes; - } - - private function instanceModel() - { - $this->model = new $this->modelClass; - $this->setTable($this->model->getTable()); - $this->setOwner($this->model->getConnectionName()); - } -} diff --git a/app/Helpers/Model/TableExtractor.php b/app/Helpers/Model/TableExtractor.php deleted file mode 100644 index d743888..0000000 --- a/app/Helpers/Model/TableExtractor.php +++ /dev/null @@ -1,201 +0,0 @@ -setTable($tableName); - $this->setOwner($owner); - } - - public function getAttributes() : array - { - if (count($this->attributes) === 0) { - $result = DB::select(DB::raw($this->_sql_filterExtractor), array( - $this->tableName, - $this->owner, - )); - foreach ($result as $r) { - $r->column_name = strtolower($r->column_name); - $r->data_type = strtolower($r->data_type); - } - $this->attributes = $result; - } - return $this->attributes; - } - - public function toPhpProperties() : array - { - $attributes = $this->getAttributes(); - return array_map(function ($r) { - return - "{$this->e}/**". PHP_EOL . - "{$this->e}* @var ".$this->getDataTypePhp($r->data_type). PHP_EOL. - "{$this->e}*/" . PHP_EOL . - "{$this->e}protected $" . strtolower($r->column_name).';' . PHP_EOL; - }, $attributes); - } - - public function toSetters() : array - { - $attributes = $this->getAttributes(); - - return array_map(function ($r) { - return - "{$this->e}public function set" . ucfirst($r->column_name) . "(" . $this->getDataTypePhp($r->data_type) . " $".$r->column_name.")" . PHP_EOL . - "{$this->e}{" . PHP_EOL . - "{$this->e}{$this->e}\$this->".strtolower($r->column_name). " = $" . $r->column_name . ";" . PHP_EOL . - "{$this->e}}" . PHP_EOL; - }, $attributes); - } - - public function toGetters() : array - { - $attributes = $this->getAttributes(); - - return array_map(function ($r) { - return - "{$this->e}public function get" . ucfirst($r->column_name) . "()" . $this->getDataTypePhp($r->data_type, true) . PHP_EOL . - "{$this->e}{" . PHP_EOL . - "{$this->e}{$this->e}return \$this->".strtolower($r->column_name). ";" . PHP_EOL . - "{$this->e}}" . PHP_EOL; - }, $attributes); - } - - public function toSwaggerAnnotation($entityName = 'Entity') - { - $swagger = ""; - $attributes = $this->getAttributes(); - $swagger.='/**' . PHP_EOL; - $swagger.=' * @OA\Schema(' . PHP_EOL; - $swagger.=' * schema="'.$entityName.'",' . PHP_EOL; - $swagger.=' * type="object",' . PHP_EOL; - $swagger.=' * description="'.$entityName.' entity",' . PHP_EOL; - $swagger.=' * title="'.$entityName.' entity",' . PHP_EOL; - foreach ($attributes as $at) { - $type = 'type="'.$at->data_type.'"'; - if ($at->data_type === 'float') { - $type = 'type="number", format="float", example="15.99"'; - } - if ($at->data_type === 'date') { - $type = 'type="string", format="date", example="dd/mm/YYYY"'; - } - $swagger.=' * @OA\Property(property="'.$at->column_name.'", '.$type.', description="'.ucfirst($at->column_name).'"),' . PHP_EOL; - } - $swagger.=" * )" . PHP_EOL; - $swagger.=" */"; - return $swagger; - } - - public function getDataTypePhp($dataType, $return = false) - { - $valor = ""; - switch ($dataType): - case 'string': - $valor = 'string'; - break; - case 'float': - $valor = 'float'; - break; - case 'integer': - $valor = 'int'; - break; - case 'array': - $valor = 'array'; - break; - default: - $valor = ''; - break; - endswitch; - - if ($return === true && !empty($valor)) { - $valor = ' : ' . $valor; - } - return $valor; - } - - protected function setTable($table) - { - $this->tableName = strtoupper($table); - } - - protected function setOwner($owner) - { - $this->owner = strtoupper($owner); - } - - protected function createColumn($columName, $dataType) : \stdClass - { - $obj = new \stdClass(); - $obj->column_name = strtolower($columName); - $obj->data_type = strtolower($dataType); - return $obj; - } - - protected function getDataTypeByValue($value) - { - // verificando se é numerico - if (is_object($value)===false && is_numeric(str_replace(',', '.', $value))) { - // verificando se é float - if (strpos($value, ",")!==false || strpos($value, ".")!==false) { - return "float"; - } else { - return "integer"; - } - } elseif (is_string($value)) { - return "string"; - } elseif (is_array($value)) { - return "array"; - } else { - return ""; - } - } -} diff --git a/app/Helpers/Model/filter/FieldFilterBuilder.php b/app/Helpers/Model/filter/FieldFilterBuilder.php deleted file mode 100644 index f49885f..0000000 --- a/app/Helpers/Model/filter/FieldFilterBuilder.php +++ /dev/null @@ -1,26 +0,0 @@ -fields; - } - - public function setFields(array $fields) - { - $this->fields = $fields; - } -} diff --git a/app/Helpers/Model/filter/FilterBuilder.php b/app/Helpers/Model/filter/FilterBuilder.php deleted file mode 100644 index 65e3dbe..0000000 --- a/app/Helpers/Model/filter/FilterBuilder.php +++ /dev/null @@ -1,159 +0,0 @@ -getFilters()) === false) { - foreach ($this->getFilters() as $filter) { - $builder = FilterType::filter($builder, $filter); - } - } - // estilo antigo - //$builder->limit($this->getLimit()); - //$builder->offset($this->getOffset()); - - /** - * Estilo novo com paginate - * Vantagem q o paginate já retorna o total - */ - $currentPage = $this->getOffset(); - \Illuminate\Pagination\Paginator::currentPageResolver(function () use ($currentPage) { - return $currentPage; - }); - foreach ($this->getOrder() as $order) { - $builder->orderBy($order->getField(), $order->getDirection()); - } - return $builder; - } - - public function getOrder(): array - { - return $this->order; - } - - public function setOrder(array $orders) - { - $this->order = $this->arrayObjectCast(OrderItem::class, $orders); - } - - public function getFilters(): array - { - return $this->filters; - } - - public function getLimit(): int - { - return $this->limit; - } - - public function getOffset(): int - { - return $this->offset; - } - - public function setFilters(array $filters) - { - $this->filters = $this->arrayObjectCast(FilterItem::class, $filters); - } - - public function addFilter(FilterItem $filter) - { - $this->filters[] = $filter; - } - - public function setLimit(int $limit) - { - $this->limit = $limit; - } - - public function setOffset(int $offset) - { - $this->offset = $offset; - } - - public function getFields() : array - { - return $this->fields; - } - - public function setFields(array $fields) - { - $this->fields = $fields; - } -} diff --git a/app/Helpers/Model/filter/FilterBuilderFactory.php b/app/Helpers/Model/filter/FilterBuilderFactory.php deleted file mode 100644 index e9f531e..0000000 --- a/app/Helpers/Model/filter/FilterBuilderFactory.php +++ /dev/null @@ -1,15 +0,0 @@ -jsonSetObject($json); - $response->setData($data); - return $response; - } -} diff --git a/app/Helpers/Model/filter/FilterBuilderResponse.php b/app/Helpers/Model/filter/FilterBuilderResponse.php deleted file mode 100644 index 7c07c8c..0000000 --- a/app/Helpers/Model/filter/FilterBuilderResponse.php +++ /dev/null @@ -1,42 +0,0 @@ -data; - } - - public function setData(array $data) - { - $this->data = $data; - } - - public function getTotal() : int - { - return $this->total; - } - - public function setTotal(int $total) - { - $this->total = $total; - } -} diff --git a/app/Helpers/Model/filter/FilterItem.php b/app/Helpers/Model/filter/FilterItem.php deleted file mode 100644 index c5947d2..0000000 --- a/app/Helpers/Model/filter/FilterItem.php +++ /dev/null @@ -1,111 +0,0 @@ -=", description="Tipo do filtro podendo ser: =,<>,>,>=,<,<=,between,not_between,like,not_like,in,not_in"), - * @OA\Property(property="field", type="string", description="Campo a ser ordernado (tem ser um campo valido)"), - * @OA\Property(property="value", type="string", example="30", description="Valor a ser filtrado. No between e in usar array nos outros casos usar um valor normal (sem ser numerico)."), - * ) - * - * @OA\Schema( - * schema="FilterItemFilterList", - * allOf={ - * @OA\Schema(ref="#/components/schemas/FilterItemFilter") - * } - * ) - */ -class FilterItem extends EntityJson -{ - /** - * @var string - */ - protected $type = "="; - - /** - * @var string - */ - protected $field; - - /** - * - * @var mixed - */ - protected $value; - - /** - * @var bool - */ - protected bool $row = false; - - /** - * @return bool - */ - public function getRow(): bool - { - return $this->row; - } - - /** - * @param bool $row - */ - public function setRow(bool $row): void - { - $this->row = $row; - } - - - public function getType() : string - { - return $this->type; - } - - public function getField() :Expression|string - { - return $this->field; - } - - public function getValue() - { - return $this->value; - } - - public function setType(string $type) - { - $this->type = $type; - } - - public function setField($field) - { - $this->field = $field; - } - - public function setValue($value) - { - $this->value = $value; - } -} diff --git a/app/Helpers/Model/filter/FilterType.php b/app/Helpers/Model/filter/FilterType.php deleted file mode 100644 index f90fbe2..0000000 --- a/app/Helpers/Model/filter/FilterType.php +++ /dev/null @@ -1,120 +0,0 @@ -", - ">", - ">=", - "<", - "<=", - "like", - "not_like" - ); - - const IN_FILTER = array( - "in", - "not_in" - ); - - const BETWEEN_FILTER = array( - "between", - "not_between" - ); - - const NULL_FILTER = array( - "null", - "not_null" - ); - - const DATE_FILTER = [ - - ]; - - public static function filter(Builder $builder, FilterItem $filter) : Builder - { - if (in_array($filter->getType(), self::WHERE_FILTER)) { - return self::MAKE_WHERE_FILTER($builder, $filter); - } - if (in_array($filter->getType(), self::IN_FILTER)) { - return self::MAKE_IN_FILTER($builder, $filter); - } - - if (in_array($filter->getType(), self::BETWEEN_FILTER)) { - return self::MAKE_BETWEEN_FILTER($builder, $filter); - } - - if (in_array($filter->getType(), self::NULL_FILTER)) { - return self::MAKE_NULL_FILTER($builder, $filter); - } - - if (in_array($filter->getType(), self::DATE_FILTER)){ - - } - - return $builder; - } - - private static function MAKE_WHERE_FILTER(Builder $builder, FilterItem $filter) : Builder - { - $fType = $filter->getType(); - // filtro not_like sem o underscore (deixo o _ por padrao) - if ($fType === 'not_like') { - $fType = 'not like'; - } - - $field = ($filter->getRow()) ? DB::raw($filter->getField()) : $filter->getField(); - - return $builder->where($field, $fType, $filter->getValue()); - } - - private static function MAKE_IN_FILTER(Builder $builder, FilterItem $filter) : Builder - { - if ($filter->getType() === "in") { - return $builder->whereIn($filter->getField(), $filter->getValue()); - } elseif ($filter->getType() === "not_in") { - return $builder->whereNotIn($filter->getField(), $filter->getValue()); - } - - return $builder; - } - - private static function MAKE_BETWEEN_FILTER(Builder $builder, FilterItem $filter) : Builder - { - if ($filter->getType() === "between") { - return $builder->whereBetween($filter->getField(), $filter->getValue()); - } elseif ($filter->getType() === "not_between") { - return $builder->whereNotBetween($filter->getField(), $filter->getValue()); - } - - return $builder; - } - - private static function MAKE_NULL_FILTER(Builder $builder, FilterItem $filter) : Builder - { - if ($filter->getType() === "null") { - return $builder->whereNull($filter->getField()); - } elseif ($filter->getType() === "not_null") { - return $builder->whereNotNull($filter->getField()); - } - - return $builder; - } -} diff --git a/app/Helpers/Model/filter/IFilterBuilder.php b/app/Helpers/Model/filter/IFilterBuilder.php deleted file mode 100644 index e55d6a0..0000000 --- a/app/Helpers/Model/filter/IFilterBuilder.php +++ /dev/null @@ -1,15 +0,0 @@ -field; - } - - public function setField(string $field) - { - $this->field = $field; - } - - public function getDirection() : string - { - return $this->direction; - } - - public function setDirection(string $direction="asc") - { - $this->direction = $direction; - } -} diff --git a/app/Http/Controllers/AboutUsController.php b/app/Http/Controllers/AboutUsController.php index 428ac54..9056670 100644 --- a/app/Http/Controllers/AboutUsController.php +++ b/app/Http/Controllers/AboutUsController.php @@ -6,7 +6,6 @@ namespace App\Http\Controllers; use App\Http\Requests\StoreAboutUsRequest; use App\Http\Resources\AboutUsResource; -use App\Models\AboutUs; use App\Repositories\AboutUs\AboutUsContractInterface; use App\Traits\ApiResponse; use Illuminate\Http\Response; diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index c805a96..5ea0150 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -1,5 +1,7 @@ getContent()); - if (isset($jsonData)) { - $obj = new $className; - if (method_exists($obj, 'jsonToObject')) { - $obj->jsonSetObject($jsonData); - return $obj; - } - } else { - throw new Exception("Request inválido"); - } - } - - public function getFilterBuilder() : ?FilterBuilder - { - return $this->getJsonObject(FilterBuilder::class); - } - - public function getFieldFilterBuilder() : ?FieldFilterBuilder - { - return $this->getJsonObject(FieldFilterBuilder::class); - } -} diff --git a/app/Http/Requests/ForgotPasswordRequest.php b/app/Http/Requests/ForgotPasswordRequest.php index 448e1a7..b44036f 100644 --- a/app/Http/Requests/ForgotPasswordRequest.php +++ b/app/Http/Requests/ForgotPasswordRequest.php @@ -1,5 +1,7 @@ role); + return [ 'name' => 'required|string|max:255|min:3', 'email' => [ @@ -31,8 +37,9 @@ class StoreUserRequest extends FormRequest "unique:users,email" ], 'password'=> 'required|string|min:6|confirmed', - 'client_id' => 'nullable', - 'profile_picture' =>'nullable|image|max:1024' + 'client_id' => ['nullable'], + 'profile_picture' =>'nullable|image|max:1024', + 'role' => ['required', new Uppercase($this->client_id)] ]; } } diff --git a/app/Http/Requests/UploadInfoSectorialRequest.php b/app/Http/Requests/UploadInfoSectorialRequest.php index d359cf7..564bcb7 100644 --- a/app/Http/Requests/UploadInfoSectorialRequest.php +++ b/app/Http/Requests/UploadInfoSectorialRequest.php @@ -1,5 +1,7 @@ format('m/Y') + return $this->execute($fields) - ->where(DB::raw("TO_CHAR(TO_DATE(pld.mes_ref, 'YYMM'), 'MM/YYYY')"), '=', '04/2022') + ->where(DB::raw("TO_CHAR(TO_DATE(pld.mes_ref, 'YYMM'), 'MM/YYYY')"), '=', Carbon::now()->format('m/Y')) ->groupBy(['submarket', 'year_month', 'year_month_formatted']) ->get(); } diff --git a/app/Rules/Uppercase.php b/app/Rules/Uppercase.php new file mode 100644 index 0000000..74962cb --- /dev/null +++ b/app/Rules/Uppercase.php @@ -0,0 +1,45 @@ +code == null){ + return false; + } + } + return true; + } + + /** + * Get the validation error message. + * + * @return string + */ + public function message() + { + return 'The client field is required.'; + } +} diff --git a/app/Support/FilterBuilder/Entity/FilterItem.php b/app/Support/FilterBuilder/Entity/FilterItem.php index 1fcbfc9..a1c7864 100644 --- a/app/Support/FilterBuilder/Entity/FilterItem.php +++ b/app/Support/FilterBuilder/Entity/FilterItem.php @@ -1,5 +1,7 @@