Skip to content

Commit

Permalink
Merge pull request #964 from portabilis/portabilis-patch-2024-08-21
Browse files Browse the repository at this point in the history
Portábilis Patch 21/08/2024
  • Loading branch information
edineivaldameri authored Aug 22, 2024
2 parents 268c367 + 926c845 commit d19b2b3
Show file tree
Hide file tree
Showing 329 changed files with 3,973 additions and 2,317 deletions.
4 changes: 1 addition & 3 deletions app/Events/RegistrationCopyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ class RegistrationCopyEvent
*
* @return void
*/
public function __construct(public LegacyRegistration $newRegistration, public LegacyRegistration $oldRegistration)
{
}
public function __construct(public LegacyRegistration $newRegistration, public LegacyRegistration $oldRegistration) {}
}
3 changes: 1 addition & 2 deletions app/Events/ReportIssued.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public function __construct(
public string $template,
public bool $success,
public bool $authenticate = false,
) {
}
) {}

public function replace(string $content): void
{
Expand Down
4 changes: 1 addition & 3 deletions app/Events/UserDeleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ class UserDeleted
use InteractsWithSockets;
use SerializesModels;

public function __construct(public User $user)
{
}
public function __construct(public User $user) {}
}
4 changes: 1 addition & 3 deletions app/Events/UserUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ class UserUpdated
use InteractsWithSockets;
use SerializesModels;

public function __construct(public User $user)
{
}
public function __construct(public User $user) {}
}
4 changes: 1 addition & 3 deletions app/Exceptions/Registration/RegistrationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Exception;

class RegistrationException extends Exception
{
}
class RegistrationException extends Exception {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Throwable;

interface DisciplinesValidationException extends Throwable
{
}
interface DisciplinesValidationException extends Throwable {}
4 changes: 1 addition & 3 deletions app/Exceptions/Transfer/TransferException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Exception;

class TransferException extends Exception
{
}
class TransferException extends Exception {}
2 changes: 1 addition & 1 deletion app/Extensions/LegacyUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function validateCredentials(Authenticatable $user, array $credentials)
{
if ($user->isInactive()) {
throw ValidationException::withMessages([
$user->login => __('auth.inactive'),
$user->login => $user->employee->motivo ?: __('auth.inactive'),
]);
}

Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function validateLogin(Request $request)
$this->username() => 'required|string',
'password' => 'required|string',
'grecaptcha' => [new ReCaptchaV3()],
], [
$this->username() . '.required' => 'O campo matrícula é obrigatório.',
$this->username() . '.string' => 'O campo matrícula é obrigatório.',
'password.required' => 'O campo senha é obrigatório.',
'password.string' => 'O campo senha é obrigatório.',
]);
}
}
3 changes: 1 addition & 2 deletions app/Jobs/EnrollmentsPromotionJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public function __construct(
private int $enrollmentId,
private string $databaseConnection,
private bool $updateScore = false
) {
}
) {}

public function handle(DatabaseManager $manager, PromocaoApiController $promocaoApiController): void
{
Expand Down
4 changes: 1 addition & 3 deletions app/Jobs/FileExporterJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class FileExporterJob implements ShouldQueue

public $retryAfter = 5;

public function __construct(private FileExport $fileExport, private array $args)
{
}
public function __construct(private FileExport $fileExport, private array $args) {}

public function handle()
{
Expand Down
11 changes: 10 additions & 1 deletion app/Listeners/AuthenticatedUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Portabilis_Date_Utils;

class AuthenticatedUser
{
Expand All @@ -29,7 +30,15 @@ public function handle(Authenticated $event)
Auth::logout();

throw ValidationException::withMessages([
$event->user->login => __('auth.inactive'),
$event->user->login => $event->user->employee->motivo ?: __('auth.inactive'),
]);
}

if ($event->user->isNotStarted()) {
Auth::logout();

throw ValidationException::withMessages([
$event->user->login => __('auth.not_started', ['date' => Portabilis_Date_Utils::pgSQLToBr($event->user->employee->data_inicial)]),
]);
}

Expand Down
3 changes: 3 additions & 0 deletions app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Database\Eloquent\Model;

/**
* @property array<int, string> $fillable
*/
class Backup extends Model
{
public $table = 'pmieducar.backup';
Expand Down
18 changes: 17 additions & 1 deletion app/Models/Builders/EmployeeAllocationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

class EmployeeAllocationBuilder extends LegacyBuilder
{
/**
* Filtra por Ano
*/
public function whereYearEq(int $year): self
{
return $this->where('ano', $year);
}

/**
* Filtra por Escola
*/
Expand All @@ -25,6 +33,14 @@ public function whereEmployee(int $employee): self
*/
public function whereInstitution(int $institution): self
{
return $this->where('ref_ref_cod_instituicao', $institution);
return $this->where($this->model->getTable() . '.ref_ref_cod_instituicao', $institution);
}

/**
* Filtra por ativo
*/
public function active(): self
{
return $this->where($this->model->getTable() . '.ativo', 1);
}
}
36 changes: 36 additions & 0 deletions app/Models/Builders/EmployeeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,40 @@ public function whereRole(string $role): self
$q->whereRaw('matricula ~* ?', $role);
});
}

/**
* Filtra por servidores ativos
*/
public function active(): self
{
return $this->where('servidor.ativo', 1);
}

/**
* Filtra por servidores que são professores
*/
public function professor(bool $onlyTeacher = true): self
{
return $this->join('pmieducar.servidor_funcao', 'servidor_funcao.ref_cod_servidor', '=', 'servidor.cod_servidor')
->join('pmieducar.funcao', 'funcao.cod_funcao', '=', 'servidor_funcao.ref_cod_funcao')
->where('funcao.professor', (int) $onlyTeacher);
}

/**
* Filtra servidores alocados no último ano
*/
public function lastYear(): self
{
return $this->join('pmieducar.servidor_alocacao', 'servidor.cod_servidor', '=', 'servidor_alocacao.ref_cod_servidor')
->where('servidor_alocacao.ano', date('Y') - 1);
}

/**
* Filtra servidores alocados no ano corrente
*/
public function currentYear(): self
{
return $this->join('pmieducar.servidor_alocacao', 'servidor.cod_servidor', '=', 'servidor_alocacao.ref_cod_servidor')
->where('servidor_alocacao.ano', date('Y'));
}
}
14 changes: 14 additions & 0 deletions app/Models/Builders/EmployeeGraduationBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Models\Builders;

class EmployeeGraduationBuilder extends LegacyBuilder
{
/**
* Filtra pelo ID do servidor
*/
public function ofEmployee(?int $employeeId): self
{
return $this->where('employee_id', $employeeId);
}
}
14 changes: 14 additions & 0 deletions app/Models/Builders/EmployeePosgraduateBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Models\Builders;

class EmployeePosgraduateBuilder extends LegacyBuilder
{
/**
* Filtra pelo ID do servidor
*/
public function ofEmployee(?int $employeeId): self
{
return $this->where('employee_id', $employeeId);
}
}
5 changes: 5 additions & 0 deletions app/Models/Builders/LegacyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
return parent::where($column, $operator, $value, $boolean);
}

public function whereRaw($sql, $bindings = [], $boolean = 'and')
{
return parent::whereRaw($sql, $bindings, $boolean);
}

public function whereIn($column, $values, $boolean = 'and', $not = false)
{
if (is_string($column)) {
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Builders/LegacyDisciplineExemptionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public function orderByCreatedAt(string $direction = 'desc'): self
{
return $this->orderBy('data_cadastro', $direction);
}

public function active(): self
{
return $this->where('ativo', 1);
}
}
24 changes: 18 additions & 6 deletions app/Models/Builders/LegacyEnrollmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public function notActive(): self
/**
* Filtra por validos
*/
public function whereValid(): self
public function whereValid(): LegacyBuilder
{
return $this->where(function ($q) {
$q->active();
$q->orWhere('transferido', true);
$q->orWhere('remanejado', true);
$q->orWhere('reclassificado', true);
$q->orWhere('abandono', true);
$q->orWhere('falecido', true);
$q->orWhere('matricula_turma.transferido', true);
$q->orWhere('matricula_turma.remanejado', true);
$q->orWhere('matricula_turma.reclassificado', true);
$q->orWhere('matricula_turma.abandono', true);
$q->orWhere('matricula_turma.falecido', true);
$q->orWhereHas('registration', fn ($q) => $q->where('dependencia', true));
});
}
Expand All @@ -70,6 +70,18 @@ public function addJoinViewSituacaoRelatorios(int $situation): self
]);
}

public function addJoinViewSituacao(int $situation): self
{
return $this->join('relatorio.view_situacao', function ($join) use ($situation) {
$join->on('view_situacao.cod_matricula', 'ref_cod_matricula');
$join->on('view_situacao.cod_turma', 'ref_cod_turma');
$join->on('view_situacao.sequencial', 'matricula_turma.sequencial');
$join->where('view_situacao.cod_situacao', $situation);
})->addSelect([
'view_situacao.texto_situacao',
]);
}

public function wherePeriod(int $period): self
{
return $this->where(function ($q) use ($period) {
Expand Down
38 changes: 38 additions & 0 deletions app/Models/Builders/LegacyRegistrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,42 @@ public function whereDifferentiatedLocalizationArea(int $differentiatedLocalizat
{
return $this->whereHas('school', fn ($q) => $q->whereDifferentiatedLocalizationArea($differentiatedLocalizationArea));
}

/**
* Filtra por alunos do sexo masculino
*/
public function male(): self
{
return $this->join('pmieducar.aluno', 'aluno.cod_aluno', '=', 'matricula.ref_cod_aluno')
->join('cadastro.fisica', 'aluno.ref_idpes', '=', 'fisica.idpes')
->where('aluno.ativo', 1)
->where('sexo', 'M');
}

/**
* Filtra por alunos do sexo feminino
*/
public function female(): self
{
return $this->join('pmieducar.aluno', 'aluno.cod_aluno', '=', 'matricula.ref_cod_aluno')
->join('cadastro.fisica', 'aluno.ref_idpes', '=', 'fisica.idpes')
->where('aluno.ativo', 1)
->where('sexo', 'F');
}

/**
* Filtra por registros do ano anterior
*/
public function lastYear(): self
{
return $this->where('matricula.ano', date('Y') - 1);
}

/**
* Filtra por registros do ano corrente
*/
public function currentYear(): self
{
return $this->where('matricula.ano', date('Y'));
}
}
16 changes: 16 additions & 0 deletions app/Models/Builders/LegacyRoleBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Models\Builders;

class LegacyRoleBuilder extends LegacyBuilder
{
public function ativo(): self
{
return $this->where('ativo', 1);
}

public function professor(): self
{
return $this->where('professor', 1);
}
}
14 changes: 14 additions & 0 deletions app/Models/Builders/LegacyStageTypeBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Models\Builders;

class LegacyStageTypeBuilder extends LegacyBuilder
{
/**
* Filtra por registros ativos
*/
public function active(): self
{
return $this->where('ativo', 1);
}
}
Loading

0 comments on commit d19b2b3

Please sign in to comment.