Skip to content

Commit e45b7c4

Browse files
committed
fix filament resource notify
1 parent 4a0475b commit e45b7c4

File tree

9 files changed

+20
-26
lines changed

9 files changed

+20
-26
lines changed

app/Filament/Resources/System/AgentAllowResource/Pages/ListAgentAllows.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ protected function getHeaderActions(): array
2828
$agentAllowRep = new AgentAllowRepository();
2929
try {
3030
$result = $agentAllowRep->checkClient($data['peer_id'], $data['agent']);
31-
$this->notify('success', __('admin.resources.agent_allow.check_pass_msg', ['id' => $result->id]));
31+
send_admin_success_notification(__('admin.resources.agent_allow.check_pass_msg', ['id' => $result->id]));
3232
} catch (\Exception $exception) {
33-
$this->notify('danger', $exception->getMessage());
33+
send_admin_fail_notification($exception->getMessage());
3434
}
3535
})
3636

app/Filament/Resources/System/ExamResource/Pages/CreateExam.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function create(bool $another = false): void
1717
$examRep = new ExamRepository();
1818
try {
1919
$this->record = $examRep->store($data);
20-
$this->notify('success', $this->getCreatedNotificationTitle());
20+
send_admin_success_notification();
2121
if ($another) {
2222
// Ensure that the form record is anonymized so that relationships aren't loaded.
2323
$this->form->model($this->record::class);
@@ -30,7 +30,7 @@ public function create(bool $another = false): void
3030
$this->redirect($this->getResource()::getUrl('index'));
3131
} catch (\Exception $exception) {
3232
do_log($exception->getMessage() . "\n" . $exception->getTraceAsString(), "error");
33-
$this->notify('danger', $exception->getMessage());
33+
send_admin_fail_notification($exception->getMessage());
3434
}
3535
}
3636

app/Filament/Resources/System/ExamResource/Pages/EditExam.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotificat
2424
$examRep = new ExamRepository();
2525
try {
2626
$this->record = $examRep->update($data, $this->record->id);
27-
$this->notify('success', $this->getSavedNotificationTitle());
27+
send_admin_success_notification();
2828
$this->redirect($this->getResource()::getUrl('index'));
2929
} catch (\Exception $exception) {
30-
$this->notify('danger', $exception->getMessage());
30+
send_admin_fail_notification($exception->getMessage());
3131
}
3232
}
3333
}

app/Filament/Resources/System/SeedBoxRecordResource/Pages/EditSeedBoxRecord.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotificat
2424
$rep = new SeedBoxRepository();
2525
try {
2626
$this->record = $rep->update($data, $this->record->id);
27-
$this->notify('success', $this->getSavedNotificationTitle());
27+
send_admin_success_notification();
2828
$this->redirect($this->getResource()::getUrl('index'));
2929
} catch (\Exception $exception) {
30-
$this->notify('danger', $exception->getMessage());
30+
send_admin_fail_notification($exception->getMessage());
3131
}
3232
}
3333
}

app/Filament/Resources/System/SeedBoxRecordResource/Pages/ListSeedBoxRecords.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ protected function getHeaderActions(): array
2626
->action(function ($data) {
2727
try {
2828
isIPSeedBox($data['ip'], $data['uid'], true, true);
29-
$this->notify('success', nexus_trans("seed-box.is_seed_box_no"));
29+
send_admin_success_notification(nexus_trans("seed-box.is_seed_box_no"));
3030
} catch (SeedBoxYesException $exception) {
31-
$this->notify('danger', nexus_trans("seed-box.is_seed_box_yes", ['id' => $exception->getId()]));
31+
send_admin_fail_notification(nexus_trans("seed-box.is_seed_box_yes", ['id' => $exception->getId()]));
3232
} catch (\Throwable $throwable) {
3333
do_log($throwable->getMessage() . $throwable->getTraceAsString(), "error");
34-
$this->notify('danger', $throwable->getMessage());
34+
send_admin_fail_notification($throwable->getMessage());
3535
}
3636
})
3737
];

app/Filament/Resources/User/ExamUserResource/Pages/ViewExamUser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ protected function getHeaderActions(): array
8181
$examRep = new ExamRepository();
8282
try {
8383
$examRep->avoidExamUser($this->record->id);
84-
$this->notify('success', 'Success !');
84+
send_admin_success_notification();
8585
$this->record = $this->resolveRecord($this->record->id);
8686
} catch (\Exception $exception) {
87-
$this->notify('danger', $exception->getMessage());
87+
send_admin_fail_notification($exception->getMessage());
8888
}
8989
})
9090
->label(__('admin.resources.exam_user.action_avoid')),
@@ -106,10 +106,10 @@ protected function getHeaderActions(): array
106106
$examRep = new ExamRepository();
107107
try {
108108
$examRep->updateExamUserEnd($this->record, Carbon::parse($data['end']), $data['reason'] ?? "");
109-
$this->notify('success', 'Success !');
109+
send_admin_success_notification();
110110
$this->record = $this->resolveRecord($this->record->id);
111111
} catch (\Exception $exception) {
112-
$this->notify('danger', $exception->getMessage());
112+
send_admin_fail_notification($exception->getMessage());
113113
}
114114
})
115115
->label(__('admin.resources.exam_user.action_update_end')),

app/Filament/Resources/User/HitAndRunResource/Pages/ViewHitAndRun.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ protected function getHeaderActions(): array
8888
$hitAndRunRep = new HitAndRunRepository();
8989
try {
9090
$hitAndRunRep->pardon($this->record->id, Auth::user());
91-
$this->notify('success', 'Success !');
91+
send_admin_success_notification();
9292
$this->record = $this->resolveRecord($this->record->id);
9393
} catch (\Exception $exception) {
94-
$this->notify('danger', $exception->getMessage());
94+
send_admin_fail_notification($exception->getMessage());
9595
}
9696
})
9797
->label(__('admin.resources.hit_and_run.action_pardon'))

app/Filament/Resources/User/UserResource/Pages/CreateUser.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@ public function create(bool $another = false): void
1818
$data = $this->form->getState();
1919
try {
2020
$this->record = $userRep->store($data);
21-
$this->notify(
22-
'success ',
23-
$this->getCreatedNotificationTitle(),
24-
);
21+
send_admin_success_notification();
2522
$this->redirect($this->getRedirectUrl());
2623
} catch (\Exception $exception) {
27-
$this->notify(
28-
'danger',
29-
$exception->getMessage(),
30-
);
24+
send_admin_fail_notification($exception->getMessage());
3125
}
3226
}
3327
}

app/Filament/Resources/User/UserResource/Pages/UserProfile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private function buildConfirmAction()
250250
->requiresConfirmation()
251251
->action(function () {
252252
if (Auth::user()->class <= $this->record->class) {
253-
$this->notify('danger', 'No permission!');
253+
send_admin_fail_notification("No permission!");
254254
return;
255255
}
256256
$this->record->status = User::STATUS_CONFIRMED;

0 commit comments

Comments
 (0)