Compare commits
No commits in common. "2ae41c2f8303e22d97d82886ec0b33918f30dd42" and "9da452d505c8f8bd535f019150a8bcd0bd25627e" have entirely different histories.
2ae41c2f83
...
9da452d505
@ -261,12 +261,6 @@ public function permissions(): array
|
||||
self::ADMIN_BAHAN_BAKU => [
|
||||
Permission::DASHBOARD_VIEW,
|
||||
|
||||
Permission::EMPLOYEES_VIEW,
|
||||
Permission::EMPLOYEES_CREATE,
|
||||
Permission::EMPLOYEES_UPDATE,
|
||||
Permission::EMPLOYEES_TOGGLE_STATUS,
|
||||
Permission::EMPLOYEES_DELETE,
|
||||
|
||||
Permission::LEAVE_REQUESTS_VIEW,
|
||||
Permission::LEAVE_REQUESTS_CREATE,
|
||||
Permission::LEAVE_REQUESTS_UPDATE,
|
||||
|
||||
@ -64,7 +64,7 @@ public function create(): Response
|
||||
|
||||
public function store(EmployeeRequest $request): RedirectResponse
|
||||
{
|
||||
$this->employeeService->create($request->validated(), $request->user());
|
||||
$this->employeeService->create($request->validated());
|
||||
|
||||
$this->flashCreated('Pegawai');
|
||||
|
||||
@ -86,16 +86,16 @@ public function edit(User $user): Response
|
||||
|
||||
public function update(EmployeeRequest $request, User $user): RedirectResponse
|
||||
{
|
||||
$this->employeeService->update($user, $request->validated(), $request->user());
|
||||
$this->employeeService->update($user, $request->validated());
|
||||
|
||||
$this->flashUpdated('Pegawai');
|
||||
|
||||
return redirect()->route('admin.hr.employees.index');
|
||||
}
|
||||
|
||||
public function destroy(User $user, Request $request): RedirectResponse
|
||||
public function destroy(User $user): RedirectResponse
|
||||
{
|
||||
$this->employeeService->delete($user, $request->user());
|
||||
$this->employeeService->delete($user);
|
||||
|
||||
$this->flashDeleted('Pegawai');
|
||||
|
||||
@ -104,16 +104,16 @@ public function destroy(User $user, Request $request): RedirectResponse
|
||||
|
||||
public function toggleStatus(ToggleStatusRequest $request, User $user): RedirectResponse
|
||||
{
|
||||
$this->employeeService->toggleStatus($user, $request->validated(), $request->user());
|
||||
$this->employeeService->toggleStatus($user, $request->validated());
|
||||
|
||||
$this->flashStatusUpdated('Pegawai');
|
||||
|
||||
return redirect()->route('admin.hr.employees.index');
|
||||
}
|
||||
|
||||
public function resetPassword(User $user, Request $request): RedirectResponse
|
||||
public function resetPassword(User $user): RedirectResponse
|
||||
{
|
||||
$this->employeeService->resetPassword($user, $request->user());
|
||||
$this->employeeService->resetPassword($user);
|
||||
|
||||
$this->flashSuccess('Kata sandi pegawai berhasil direset.');
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
use App\Services\Concerns\RunsInTransaction;
|
||||
use App\Services\Concerns\SyncsPhotos;
|
||||
use App\Services\Media\MediaService;
|
||||
use App\Services\System\PushNotificationService;
|
||||
use App\Support\Media\MediaPresenter;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@ -23,7 +22,6 @@ class EmployeeService
|
||||
|
||||
public function __construct(
|
||||
private readonly MediaService $mediaService,
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
public function paginateForIndex(
|
||||
@ -80,10 +78,10 @@ public function findForEdit(User $user): array
|
||||
];
|
||||
}
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
public function create(array $validated): void
|
||||
{
|
||||
$this->runInTransaction(
|
||||
function () use ($validated): User {
|
||||
function () use ($validated): void {
|
||||
$user = User::create([
|
||||
'email' => $validated['email'],
|
||||
'username' => $validated['username'],
|
||||
@ -111,22 +109,14 @@ function () use ($validated): User {
|
||||
}
|
||||
|
||||
$user->syncRoles([$validated['role']]);
|
||||
|
||||
return $user;
|
||||
},
|
||||
'Gagal membuat karyawan',
|
||||
);
|
||||
|
||||
$this->cacheForgetByPattern('hr:employees:*');
|
||||
|
||||
$this->notifyOwner(
|
||||
'Tambah Pegawai',
|
||||
"Pegawai '{$validated['full_name']}' telah ditambahkan oleh {$user->profile?->full_name}.",
|
||||
route('admin.hr.employees.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function update(User $user, array $validated, User $authUser): void
|
||||
public function update(User $user, array $validated): void
|
||||
{
|
||||
$employee = $user->employee;
|
||||
|
||||
@ -179,15 +169,9 @@ function () use ($validated, $user, $employee): void {
|
||||
);
|
||||
|
||||
$this->cacheForgetByPattern('hr:employees:*');
|
||||
|
||||
$this->notifyOwner(
|
||||
'Ubah Pegawai',
|
||||
"Pegawai '{$user->profile?->full_name}' telah diperbarui oleh {$authUser->profile?->full_name}.",
|
||||
route('admin.hr.employees.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function toggleStatus(User $user, array $validated, User $authUser): void
|
||||
public function toggleStatus(User $user, array $validated): void
|
||||
{
|
||||
$this->runInTransaction(
|
||||
function () use ($user, $validated): void {
|
||||
@ -203,17 +187,9 @@ function () use ($user, $validated): void {
|
||||
);
|
||||
|
||||
$this->cacheForgetByPattern('hr:employees:*');
|
||||
|
||||
$statusLabel = $validated['is_active'] ? 'aktif' : 'nonaktif';
|
||||
|
||||
$this->notifyOwner(
|
||||
'Ubah Status Pegawai',
|
||||
"Status pegawai '{$user->profile?->full_name}' telah diubah menjadi {$statusLabel} oleh {$authUser->profile?->full_name}.",
|
||||
route('admin.hr.employees.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function resetPassword(User $user, User $authUser): void
|
||||
public function resetPassword(User $user): void
|
||||
{
|
||||
$this->runInTransaction(
|
||||
function () use ($user): void {
|
||||
@ -227,18 +203,10 @@ function () use ($user): void {
|
||||
);
|
||||
|
||||
$this->cacheForgetByPattern('hr:employees:*');
|
||||
|
||||
$this->notifyOwner(
|
||||
'Reset Kata Sandi Pegawai',
|
||||
"Kata sandi pegawai '{$user->profile?->full_name}' telah direset oleh {$authUser->profile?->full_name}.",
|
||||
route('admin.hr.employees.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(User $user, User $authUser): void
|
||||
public function delete(User $user): void
|
||||
{
|
||||
$name = $user->profile?->full_name;
|
||||
|
||||
$this->runInTransaction(
|
||||
function () use ($user): void {
|
||||
$user->employee?->delete();
|
||||
@ -249,22 +217,6 @@ function () use ($user): void {
|
||||
);
|
||||
|
||||
$this->cacheForgetByPattern('hr:employees:*');
|
||||
|
||||
$this->notifyOwner(
|
||||
'Hapus Pegawai',
|
||||
"Pegawai '{$name}' telah dihapus oleh {$authUser->profile?->full_name}.",
|
||||
route('admin.hr.employees.index'),
|
||||
);
|
||||
}
|
||||
|
||||
private function notifyOwner(string $typeLabel, string $body, string $url): void
|
||||
{
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
"📦 {$typeLabel}",
|
||||
$body,
|
||||
['owner', 'developer', 'direktur'],
|
||||
$url,
|
||||
);
|
||||
}
|
||||
|
||||
private function syncProfilePhoto(UserProfile $profile, array $validated): void
|
||||
|
||||
@ -132,7 +132,7 @@ function () use ($validated, $user): void {
|
||||
|
||||
$this->pushNotificationService->sendToUser(
|
||||
'📤 Pengajuan Terkirim',
|
||||
"Pengajuan ubah pengaturan marketplace oleh {$user->profile?->full_name} menunggu verifikasi owner.",
|
||||
\"Pengajuan ubah pengaturan marketplace oleh {$user->profile?->full_name} menunggu verifikasi owner.\",
|
||||
$user->id,
|
||||
route('admin.system.settings.index'),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user