Mostrar oportunidades publicadas antes do registo de candidatos

This commit is contained in:
2026-10-30 21:15:27 +02:00
parent bf84575d10
commit c22846b2b1
10 changed files with 528 additions and 8 deletions
+20
View File
@@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\CandidateAccount;
use App\Models\PeopleProcess;
use App\Models\User;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
@@ -15,6 +16,25 @@ use stdClass;
class CandidateSubmissions
{
/** Only explicitly published, current and open opportunities; no internal process fields.
* @return LengthAwarePaginator<int, stdClass>
*/
public function publicOpportunities(int $company, int $page = 1): LengthAwarePaginator
{
$path = '/candidaturas/'.$company;
if (! Schema::hasTable('candidate_opportunity_publications')) {
return (new LengthAwarePaginator([], 0, 12, $page))->withPath($path)->setPageName('opportunities_page');
}
return DB::table('candidate_opportunity_publications as p')->join('people_processes as r', 'r.id', '=', 'p.people_process_id')
->where('p.tenant_id', $company)->where('r.tenant_id', $company)->where('p.active', true)
->where('r.status', 'open')->where('r.closes_on', '>=', today()->toDateString())
->whereNotExists(fn ($q) => $q->selectRaw('1')->from('candidate_opportunity_publications as newer')
->whereColumn('newer.people_process_id', 'p.people_process_id')->whereColumn('newer.tenant_id', 'p.tenant_id')->whereColumn('newer.version', '>', 'p.version'))
->orderBy('r.closes_on')->orderBy('r.id')
->paginate(12, ['r.id', 'r.title', 'r.kind', 'r.closes_on', 'p.description'], 'opportunities_page', $page)->withPath($path);
}
/** @param array<string,mixed> $input */
public function publish(User $actor, int $processId, array $input): void
{