Validation of client code in the user registration.
This commit is contained in:
parent
f1f6c69062
commit
0ad3f0cf8a
@ -1,135 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description of EntityJson
|
|
||||||
*
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
abstract class EntityJson implements \JsonSerializable
|
|
||||||
{
|
|
||||||
public function jsonToObject(\stdClass $jsonData)
|
|
||||||
{
|
|
||||||
$vars = get_object_vars($jsonData);
|
|
||||||
foreach ($vars as $key => $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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers\Model;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description of ModelExtractor
|
|
||||||
*
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
class ModelExtractor extends TableExtractor
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $modelClass = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Model
|
|
||||||
*/
|
|
||||||
private $model;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(string $modelClass)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,201 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers\Model;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description of TableExtractor
|
|
||||||
*
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
class TableExtractor
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $tableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $owner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default empty space
|
|
||||||
* @var type
|
|
||||||
*/
|
|
||||||
private $e = " ";
|
|
||||||
|
|
||||||
protected $attributes = [];
|
|
||||||
|
|
||||||
|
|
||||||
private $_sql_filterExtractor = "SELECT
|
|
||||||
COLUMN_NAME,
|
|
||||||
case when DATA_TYPE = 'NUMBER' THEN
|
|
||||||
decode(data_scale,0,'INTEGER','FLOAT')
|
|
||||||
when DATA_TYPE = 'DATE' THEN
|
|
||||||
'DATE'
|
|
||||||
else
|
|
||||||
'STRING'
|
|
||||||
end as DATA_TYPE
|
|
||||||
FROM all_tab_columns where table_name = ?
|
|
||||||
and owner = ?
|
|
||||||
order by column_id";
|
|
||||||
|
|
||||||
public function __construct(string $tableName = '', string $owner = 'KDB1')
|
|
||||||
{
|
|
||||||
$this->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 "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
class FieldFilterBuilder extends FilterBuilder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected array $fields = [];
|
|
||||||
|
|
||||||
public function getFields() : array
|
|
||||||
{
|
|
||||||
return $this->fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFields(array $fields)
|
|
||||||
{
|
|
||||||
$this->fields = $fields;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
use App\Helpers\Model\EntityJson;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="FilterBuilder",
|
|
||||||
* type="object",
|
|
||||||
* description="FilterBuilder entity",
|
|
||||||
* title="FilterBuilder entity",
|
|
||||||
* @OA\Property(property="filters", type="object", ref="#/components/schemas/FilterItemFilterList"),
|
|
||||||
* @OA\Property(property="limit", type="integer", example="10",description="Limit da paginação"),
|
|
||||||
* @OA\Property(property="offset", type="integer", example="0", description="Valor da offset da paginação"),
|
|
||||||
* @OA\Property(property="order", type="object", ref="#/components/schemas/OrderItemFilterList"),
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="FilterBuilderResponse",
|
|
||||||
* type="object",
|
|
||||||
* description="FilterBuilderReponse entity",
|
|
||||||
* title="FilterBuilderReponse entity",
|
|
||||||
* allOf={
|
|
||||||
* @OA\Schema(ref="#/components/schemas/FilterBuilder")
|
|
||||||
* },
|
|
||||||
* @OA\Property(property="data", type="array", type="object", example="[{...}]", description="Array de objetos do resultado da query"),
|
|
||||||
* @OA\Property(property="total", type="integer", example="100", description="Resultado do total de linhas sem a paginação"),
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="FieldFilterBuilder",
|
|
||||||
* type="object",
|
|
||||||
* description="FieldFilterBuilder entity",
|
|
||||||
* title="FieldFilterBuilder entity",
|
|
||||||
* allOf={
|
|
||||||
* @OA\Schema(ref="#/components/schemas/FilterBuilder")
|
|
||||||
* },
|
|
||||||
* @OA\Property(property="fields", type="array", type="string", example="['cd_pessoa','nm_pessoa']"),
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
class FilterBuilder extends EntityJson implements IFilterBuilder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var FilterItem[]
|
|
||||||
*/
|
|
||||||
protected array $filters = [];
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected int $limit = 10;
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected int $offset = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var OrderItem[]
|
|
||||||
*/
|
|
||||||
protected array $order = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected array $fields = [];
|
|
||||||
|
|
||||||
|
|
||||||
public function applyFilter(Builder $builder): Builder
|
|
||||||
{
|
|
||||||
if (empty($this->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
class FilterBuilderFactory
|
|
||||||
{
|
|
||||||
public static function createFilterBuilderResponse(FilterBuilder $filter, array $data = []) : FilterBuilderResponse
|
|
||||||
{
|
|
||||||
$json = json_decode(json_encode($filter));
|
|
||||||
$response = new FilterBuilderResponse();
|
|
||||||
$response->jsonSetObject($json);
|
|
||||||
$response->setData($data);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
class FilterBuilderResponse extends FilterBuilder
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $data = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $total = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public function getData() : array
|
|
||||||
{
|
|
||||||
return $this->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setData(array $data)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTotal() : int
|
|
||||||
{
|
|
||||||
return $this->total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTotal(int $total)
|
|
||||||
{
|
|
||||||
$this->total = $total;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Helpers\Model\EntityJson;
|
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
use Illuminate\Database\Query\Expression;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FilterItem
|
|
||||||
*
|
|
||||||
* Objeto utilizado para base dos filtros, por padrão ele possui um estrutura json nesse formato
|
|
||||||
* { type: "=", field: "id_produto", value: 18832 }
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="FilterItemFilter",
|
|
||||||
* type="object",
|
|
||||||
* description="FilterItemFilter entity",
|
|
||||||
* title="FilterItemFilter entity",
|
|
||||||
* @OA\Property(property="type", type="string", example=">=", 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description of FilterType
|
|
||||||
* Filtros padrãos do laravel builder
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
class FilterType
|
|
||||||
{
|
|
||||||
const WHERE_FILTER = array(
|
|
||||||
"=",
|
|
||||||
"<>",
|
|
||||||
">",
|
|
||||||
">=",
|
|
||||||
"<",
|
|
||||||
"<=",
|
|
||||||
"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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
interface IFilterBuilder
|
|
||||||
{
|
|
||||||
public function applyFilter(Builder $builder) : Builder;
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
namespace App\Helpers\Model\filter;
|
|
||||||
|
|
||||||
use App\Entity\EntityJson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OrderItem
|
|
||||||
*
|
|
||||||
* Objeto utilizado para base dos filtros, por padrão ele possui um estrutura json nesse formato
|
|
||||||
* { field: "id_produto", direction: "asc" }
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="OrderItemFilter",
|
|
||||||
* type="object",
|
|
||||||
* description="OrderItemFilter entity",
|
|
||||||
* title="OrderItemFilter entity",
|
|
||||||
* @OA\Property(property="field", type="string", description="Campo a ser ordernado (tem ser um campo valido)"),
|
|
||||||
* @OA\Property(property="direction", type="string", example="asc", description="Direção da ordenação (asc|desc)"),
|
|
||||||
* )
|
|
||||||
*
|
|
||||||
* @OA\Schema(
|
|
||||||
* schema="OrderItemFilterList",
|
|
||||||
* allOf={
|
|
||||||
* @OA\Schema(ref="#/components/schemas/OrderItemFilter")
|
|
||||||
* }
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OrderItem extends EntityJson
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $field;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $direction = "asc";
|
|
||||||
|
|
||||||
|
|
||||||
public function getField() : string
|
|
||||||
{
|
|
||||||
return $this->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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,7 +6,6 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Http\Requests\StoreAboutUsRequest;
|
use App\Http\Requests\StoreAboutUsRequest;
|
||||||
use App\Http\Resources\AboutUsResource;
|
use App\Http\Resources\AboutUsResource;
|
||||||
use App\Models\AboutUs;
|
|
||||||
use App\Repositories\AboutUs\AboutUsContractInterface;
|
use App\Repositories\AboutUs\AboutUsContractInterface;
|
||||||
use App\Traits\ApiResponse;
|
use App\Traits\ApiResponse;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Resources\DadosCadastraisResponse;
|
use App\Http\Resources\DadosCadastraisResponse;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\UploadInfoSectorialRequest;
|
use App\Http\Requests\UploadInfoSectorialRequest;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Resources\NewsResource;
|
use App\Http\Resources\NewsResource;
|
||||||
|
|||||||
@ -12,7 +12,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
|
||||||
class NotificationController extends Controller
|
class NotificationController extends Controller
|
||||||
{
|
{
|
||||||
use ApiResponse;
|
use ApiResponse;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|||||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Helpers\Helpers;
|
|
||||||
use App\Http\Requests\StoreUserRequest;
|
use App\Http\Requests\StoreUserRequest;
|
||||||
use App\Http\Resources\UserResource;
|
use App\Http\Resources\UserResource;
|
||||||
use App\Repositories\Users\UserContractInterface;
|
use App\Repositories\Users\UserContractInterface;
|
||||||
|
|||||||
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Helpers\Model\filter\FieldFilterBuilder;
|
|
||||||
use App\Helpers\Model\filter\FilterBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description of AzuxRequest
|
|
||||||
*
|
|
||||||
* @author renan
|
|
||||||
*/
|
|
||||||
class AzuxRequest extends Request
|
|
||||||
{
|
|
||||||
public function getJsonObject($className)
|
|
||||||
{
|
|
||||||
$jsonData = json_decode($this->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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -11,7 +13,7 @@ class StoreAboutUsRequest extends FormRequest
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use App\Rules\Uppercase;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class StoreUserRequest extends FormRequest
|
class StoreUserRequest extends FormRequest
|
||||||
@ -23,6 +26,9 @@ class StoreUserRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
// (new Uppercase());
|
||||||
|
// dd($this->role);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => 'required|string|max:255|min:3',
|
'name' => 'required|string|max:255|min:3',
|
||||||
'email' => [
|
'email' => [
|
||||||
@ -31,8 +37,9 @@ class StoreUserRequest extends FormRequest
|
|||||||
"unique:users,email"
|
"unique:users,email"
|
||||||
],
|
],
|
||||||
'password'=> 'required|string|min:6|confirmed',
|
'password'=> 'required|string|min:6|confirmed',
|
||||||
'client_id' => 'nullable',
|
'client_id' => ['nullable'],
|
||||||
'profile_picture' =>'nullable|image|max:1024'
|
'profile_picture' =>'nullable|image|max:1024',
|
||||||
|
'role' => ['required', new Uppercase($this->client_id)]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
@ -11,7 +13,7 @@ class UploadInfoSectorialRequest extends FormRequest
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class AboutUsResource extends JsonResource
|
class AboutUsResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class DadosCadastraisResponse extends JsonResource
|
class DadosCadastraisResponse extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class EconomyResource extends JsonResource
|
class EconomyResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class FaqResource extends JsonResource
|
class FaqResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class NewsResource extends JsonResource
|
class NewsResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class NotificationResource extends JsonResource
|
class NotificationResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class OperationSummaryResource extends JsonResource
|
class OperationSummaryResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class OverviewResource extends JsonResource
|
class OverviewResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class PldResource extends JsonResource
|
class PldResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class TelemetryResource extends JsonResource
|
class TelemetryResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|\JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use Illuminate\Contracts\Support\Arrayable;
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
@ -9,13 +11,8 @@ use JsonSerializable;
|
|||||||
|
|
||||||
class UserResource extends JsonResource
|
class UserResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
public function toArray($request): array|JsonSerializable|Arrayable
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return array|Arrayable|JsonSerializable
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
{
|
||||||
return parent::toArray($request);
|
return parent::toArray($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Interface;
|
namespace App\Interface;
|
||||||
|
|
||||||
interface RepositoryInterfaces
|
interface RepositoryInterfaces
|
||||||
@ -9,6 +11,5 @@ interface RepositoryInterfaces
|
|||||||
public function find(int $id);
|
public function find(int $id);
|
||||||
public function update(array $params, int $id);
|
public function update(array $params, int $id);
|
||||||
public function delete(int $id);
|
public function delete(int $id);
|
||||||
public function selectGlobal($params);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\UserScope;
|
use App\Models\Scopes\UserScope;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Models\Scopes\UserScope;
|
use App\Models\Scopes\UserScope;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\AboutUs;
|
namespace App\Repositories\AboutUs;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
interface ContractInterface
|
interface ContractInterface
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\DadosCadastrais;
|
namespace App\Repositories\DadosCadastrais;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\DadosTe;
|
namespace App\Repositories\DadosTe;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Economy;
|
namespace App\Repositories\Economy;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Faqs;
|
namespace App\Repositories\Faqs;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Faqs;
|
namespace App\Repositories\Faqs;
|
||||||
|
|
||||||
use App\Models\Faq;
|
use App\Models\Faq;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Med5min;
|
namespace App\Repositories\Med5min;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Notifications;
|
namespace App\Repositories\Notifications;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Notifications;
|
namespace App\Repositories\Notifications;
|
||||||
|
|
||||||
use App\Models\Notifications;
|
use App\Models\Notifications;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Repositories\Pld;
|
namespace App\Repositories\Pld;
|
||||||
|
|
||||||
use App\Repositories\ContractInterface;
|
use App\Repositories\ContractInterface;
|
||||||
|
|||||||
@ -6,11 +6,11 @@ namespace App\Repositories\Pld;
|
|||||||
|
|
||||||
use App\Models\Pld;
|
use App\Models\Pld;
|
||||||
use App\Repositories\AbstractRepository;
|
use App\Repositories\AbstractRepository;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use function Symfony\Component\Translation\t;
|
|
||||||
|
|
||||||
class PldRepository extends AbstractRepository implements PldContractInterface
|
class PldRepository extends AbstractRepository implements PldContractInterface
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ class PldRepository extends AbstractRepository implements PldContractInterface
|
|||||||
/**
|
/**
|
||||||
* @throws BindingResolutionException
|
* @throws BindingResolutionException
|
||||||
*/
|
*/
|
||||||
public function getOverviewByRegion(): Collection|array
|
public function getOverviewByRegion(): array|Collection
|
||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'pld.submercado as submarket',
|
'pld.submercado as submarket',
|
||||||
@ -45,9 +45,9 @@ class PldRepository extends AbstractRepository implements PldContractInterface
|
|||||||
DB::raw("SUM(pld.valor) as value")
|
DB::raw("SUM(pld.valor) as value")
|
||||||
];
|
];
|
||||||
|
|
||||||
// Carbon::now()->format('m/Y')
|
|
||||||
return $this->execute($fields)
|
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'])
|
->groupBy(['submarket', 'year_month', 'year_month_formatted'])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|||||||
45
app/Rules/Uppercase.php
Normal file
45
app/Rules/Uppercase.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rules;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class Uppercase implements Rule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new rule instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
protected $code
|
||||||
|
){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the validation rule passes.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function passes($attribute, $value): bool
|
||||||
|
{
|
||||||
|
if ($value == 2) {
|
||||||
|
if ( $this->code == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation error message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return 'The client field is required.';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder\Entity;
|
namespace App\Support\FilterBuilder\Entity;
|
||||||
|
|
||||||
use App\Support\FilterBuilder\EntityJson;
|
use App\Support\FilterBuilder\EntityJson;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder\Entity;
|
namespace App\Support\FilterBuilder\Entity;
|
||||||
|
|
||||||
use App\Support\FilterBuilder\EntityJson;
|
use App\Support\FilterBuilder\EntityJson;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder;
|
namespace App\Support\FilterBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder;
|
namespace App\Support\FilterBuilder;
|
||||||
|
|
||||||
use App\Support\FilterBuilder\Entity\FilterItem;
|
use App\Support\FilterBuilder\Entity\FilterItem;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder;
|
namespace App\Support\FilterBuilder;
|
||||||
|
|
||||||
use App\Support\FilterBuilder\Entity\FilterItem;
|
use App\Support\FilterBuilder\Entity\FilterItem;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder;
|
namespace App\Support\FilterBuilder;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Support\FilterBuilder\Interfaces;
|
namespace App\Support\FilterBuilder\Interfaces;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|||||||
15
database/factories/AboutUsFactory.php
Normal file
15
database/factories/AboutUsFactory.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class AboutUsFactory extends Factory
|
||||||
|
{
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user