File manager - Edit - /var/www/html/homologBancodetalentos/app/Http/Controllers/Web/TalentBank/AdminWebController.php
Back
<?php namespace App\Http\Controllers\Web\TalentBank; use App\Http\Controllers\Controller; use App\Http\Services\TalentBank\CandidateService; use App\Http\Services\TalentBank\JobService; use App\Support\TalentBank\JobListingQuery; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\View\View; class AdminWebController extends Controller { private CandidateService $candidateService; private JobService $jobService; public function __construct() { $this->candidateService = new CandidateService(); $this->jobService = new JobService(); } public function candidates(Request $request): View { if (! $request->filled('sort')) { $request->merge(['sort' => 'id,desc']); } $candidates = $this->candidateService->paginateRessource( $request, \App\Http\Resources\TalentBank\CandidateCollection::class ); return view('talent-bank.admin.candidates', [ 'candidates' => $candidates, ]); } public function report(Request $request): View { if ($request->filled('q')) { $request->merge(['like' => 'name,'.$request->input('q')]); } if ($request->filled('neighbourhood_id')) { $request->merge(['neighbourhoods' => (string) $request->input('neighbourhood_id')]); } if ($request->filled('occupation_id')) { $request->merge(['occupations' => (string) $request->input('occupation_id')]); } $paginated = $this->candidateService->reportPaginated($request); $paginatorItems = $paginated->items(); $counters = $paginatorItems['counters'] ?? []; $list = $paginatorItems['list'] ?? collect(); $rows = collect(is_object($list) && method_exists($list, 'toArray') ? $list->toArray($request) : $list); $candidateRows = $rows->get('candidates', $rows); $candidates = new LengthAwarePaginator( collect($candidateRows)->map(fn ($row) => (object) $row), $paginated->total(), $paginated->perPage(), $paginated->currentPage(), ['path' => url()->current(), 'query' => $request->query()] ); $options = $this->candidateService->getOptions(); $filterOptions = [ 'occupations' => collect($options['occupation'] ?? [])->map(fn ($row) => (object) $row), 'neighbourhoods' => collect($options['neighbourhood'] ?? [])->map(fn ($row) => (object) $row), ]; return view('talent-bank.admin.report', [ 'counters' => $counters, 'candidates' => $candidates, 'filterOptions' => $filterOptions, ]); } public function jobsAdmin(Request $request): View { if (! $request->filled('sort')) { $request->merge(['sort' => 'id,desc']); } $perPage = (int) $request->input('perPage', 15); $page = (int) $request->input('page', 1); $offset = ($page - 1) * $perPage; $query = JobListingQuery::applyAdminFilters($request) ->with(['company', 'occupation', 'candidates']); $total = (clone $query)->count(); $items = (clone $query)->offset($offset)->limit($perPage)->get(); $jobs = new LengthAwarePaginator( $items, $total, $perPage, $page, ['path' => url()->current(), 'query' => $request->query()] ); return view('talent-bank.admin.jobs', [ 'jobs' => $jobs, ]); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings