79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Presensi;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\DokSiremun\UnitKerja;
|
|
use App\Models\User;
|
|
use App\Models\Verifikator\Team;
|
|
|
|
class VerifikatorPresensiController extends Controller
|
|
{
|
|
public function index(int $unit)
|
|
{
|
|
$team = Team::where('unit_kerja_id', $unit)->firstOrFail();
|
|
setPermissionsTeamId($team->id);
|
|
$verifikators = User::select('nip', 'name')
|
|
->whereHas('permissions', function ($query) {
|
|
$query->where('name', 'Verifikasi Presensi');
|
|
})
|
|
->whereHas('teams', function ($query) use ($unit) {
|
|
$query->where('unit_kerja_id', $unit);
|
|
})
|
|
->get();
|
|
|
|
return response()->json([
|
|
'statusCode' => 200,
|
|
'status' => 'success',
|
|
'data' => $verifikators,
|
|
]);
|
|
}
|
|
|
|
public function honorer(int $unit)
|
|
{
|
|
$team = Team::where('unit_kerja_id', $unit)->firstOrFail();
|
|
setPermissionsTeamId($team->id);
|
|
$verifikators = User::select('nip', 'name')
|
|
->whereHas('permissions', function ($query) {
|
|
$query->where('name', 'Verifikasi Presensi Honorer');
|
|
})
|
|
->get();
|
|
|
|
return response()->json([
|
|
'statusCode' => 200,
|
|
'status' => 'success',
|
|
'data' => $verifikators,
|
|
]);
|
|
}
|
|
|
|
public function show(string $nip)
|
|
{
|
|
$units = UnitKerja::get();
|
|
foreach ($units as $unit) {
|
|
$team = Team::where('unit_kerja_id', $unit->id)->first();
|
|
setPermissionsTeamId($team->id);
|
|
$isVerifikator = User::whereHas('permissions', function ($query) {
|
|
$query->where('name', 'Verifikasi Presensi');
|
|
})
|
|
->where(function ($query) use ($nip) {
|
|
$query->where('username', $nip)
|
|
->orWhere('nip', $nip);
|
|
})
|
|
->exists();
|
|
if ($isVerifikator) break;
|
|
}
|
|
|
|
return response()->json([
|
|
'statusCode' => 200,
|
|
'status' => 'success',
|
|
'data' => [
|
|
'isVerifikator' => $isVerifikator,
|
|
'unit' => [
|
|
'id' => $unit->id,
|
|
'nama' => $unit->nama,
|
|
]
|
|
]
|
|
]);
|
|
}
|
|
}
|