26 lines
613 B
PHP
26 lines
613 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\v1\Nominee;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Util;
|
|
use App\Nominee;
|
|
|
|
class GetController extends Controller
|
|
{
|
|
public function __invoke()
|
|
{
|
|
$q = Nominee::query()
|
|
->where('election_id', Util::getCurrentElection())
|
|
->orderBy('position_id');
|
|
|
|
$positionId = request('position_id');
|
|
if ($positionId !== null && $positionId !== '' && (int) $positionId !== 0) {
|
|
$q->where('position_id', (int) $positionId);
|
|
}
|
|
|
|
return $q->get();
|
|
}
|
|
}
|