- Updated CustomerService to simplify getAll method. - Refactored ProductService to utilize HasRoleChecks trait and improved role verification logic. - Enhanced ProductVariantService with new methods for fetching data for restocking and transactions. - Cleaned up RawMaterialService by removing unused methods and improving data retrieval. - Adjusted SupplierService to streamline getAll method. - Refactored RoleService to use Spatie's Role model and improved role filtering logic. - Updated NotificationService to handle role labels more effectively. - Improved StockMutationService by removing redundant paginated method. - Cleaned up various frontend components to directly accept necessary props instead of nested data objects. - Updated tests to reflect changes in service method names and ensure proper notification handling.
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\HR;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\HR\AttendanceRequest;
|
|
use App\Models\Attendance;
|
|
use App\Services\Admin\HR\AttendanceService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class AttendanceController extends Controller
|
|
{
|
|
public function __construct(
|
|
private AttendanceService $service
|
|
) {}
|
|
|
|
public function index(Request $request): Response
|
|
{
|
|
$year = $request->integer('year', now()->year);
|
|
$month = $request->integer('month', now()->month);
|
|
|
|
return Inertia::render('admin/hr/attendance/index', [
|
|
...$this->service->getIndexData($year, $month),
|
|
]);
|
|
}
|
|
|
|
public function store(AttendanceRequest $request): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->checkIn($request->validated()),
|
|
'Berhasil check-in.',
|
|
'admin.hr.attendances.index'
|
|
);
|
|
}
|
|
|
|
public function update(AttendanceRequest $request, Attendance $attendance): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->checkOut($attendance, $request->validated()),
|
|
'Berhasil check-out.',
|
|
'admin.hr.attendances.index'
|
|
);
|
|
}
|
|
|
|
public function byDate(Request $request): ?array
|
|
{
|
|
$date = $request->query('date', now()->toDateString());
|
|
|
|
return $this->service->getByDate($date);
|
|
}
|
|
}
|