init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Rules\Raas;
use App\Models\Raas\Exportacao;
use Illuminate\Contracts\Validation\Rule;
class ExportacaoContainsFinanciamento implements Rule
{
private $unidadeId;
private $competenciaId;
public function __construct($unidadeId, $competenciaId)
{
$this->unidadeId = $unidadeId;
$this->competenciaId = $competenciaId;
}
public function passes($attribute, $value)
{
$response = true;
Exportacao::where('unidade_id', $this->unidadeId)
->where('competencia_id', $this->competenciaId)
->whereHas('financiamentos', function($query) use ($value) {
$query->from('sigtap.financiamento')->whereIn('id', $value);
})
->get()
->map(function($exportacao) use ($value, &$response) {
if ($exportacao->financiamentos->count() === count($value)) {
$response = false;
}
});
return $response;
}
public function message()
{
return 'Exportação já existente para os financiamentos selecionados.';
}
}