[FIX] 修復員工識別卡最後使用狀態更新、刪除頁面顯示 JSON 與語系遺漏問題
1. 在 StaffCardLog 模型中實作 booted() 事件監聽器,於刷卡日誌建立後自動更新關聯員工識別卡的「最後使用時間」與「最後使用機台」,並使用 withoutGlobalScopes 確保寫入安全。 2. 修正 StaffCardController 刪除方法(destroy),判斷 AJAX 請求以回傳 JSON,其餘一般表單刪除後則正常重導向回列表頁,解決刪除時跳轉至 JSON 純文字的問題。 3. 補齊多語系語系檔(zh_TW.json, en.json, ja.json)中有關「刪除員工識別卡」的翻譯對照,確保 UI 刪除警告在不同語言環境下均能完美呈現。
This commit is contained in:
parent
e29826a0a6
commit
17c7a26ef4
@ -126,10 +126,14 @@ class StaffCardController extends Controller
|
|||||||
{
|
{
|
||||||
$staffCard->delete();
|
$staffCard->delete();
|
||||||
|
|
||||||
return response()->json([
|
if (request()->ajax()) {
|
||||||
'success' => true,
|
return response()->json([
|
||||||
'message' => __('Staff card deleted successfully'),
|
'success' => true,
|
||||||
]);
|
'message' => __('Staff card deleted successfully'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('admin.data-config.staff-cards.index')->with('success', __('Staff card deleted successfully'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleStatus(StaffCard $staffCard)
|
public function toggleStatus(StaffCard $staffCard)
|
||||||
|
|||||||
@ -30,6 +30,25 @@ class StaffCardLog extends Model
|
|||||||
'created_at' => 'datetime',
|
'created_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 註冊 Model 事件以自動更新 StaffCard 的最後使用狀態
|
||||||
|
*/
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
static::created(function ($log) {
|
||||||
|
if ($log->staff_card_id) {
|
||||||
|
// 使用 withoutGlobalScopes 確保不論在任何 Session Context 下皆能正確寫入
|
||||||
|
$staffCard = StaffCard::withoutGlobalScopes()->find($log->staff_card_id);
|
||||||
|
if ($staffCard) {
|
||||||
|
$staffCard->update([
|
||||||
|
'last_used_at' => $log->created_at ?? now(),
|
||||||
|
'last_machine_id' => $log->machine_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得關聯的員工卡片
|
* 取得關聯的員工卡片
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -144,6 +144,7 @@
|
|||||||
"Are you sure you want to delete this product?": "Are you sure you want to delete this product?",
|
"Are you sure you want to delete this product?": "Are you sure you want to delete this product?",
|
||||||
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "Are you sure you want to delete this product? All related historical translation data will also be removed.",
|
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "Are you sure you want to delete this product? All related historical translation data will also be removed.",
|
||||||
"Are you sure you want to delete this role? This action cannot be undone.": "Are you sure you want to delete this role? This action cannot be undone.",
|
"Are you sure you want to delete this role? This action cannot be undone.": "Are you sure you want to delete this role? This action cannot be undone.",
|
||||||
|
"Are you sure you want to delete this staff card? This action cannot be undone.": "Are you sure you want to delete this staff card? This action cannot be undone.",
|
||||||
"Are you sure you want to delete your account?": "Are you sure you want to delete your account?",
|
"Are you sure you want to delete your account?": "Are you sure you want to delete your account?",
|
||||||
"Are you sure you want to disable this advertisement?": "Are you sure you want to disable this advertisement?",
|
"Are you sure you want to disable this advertisement?": "Are you sure you want to disable this advertisement?",
|
||||||
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "Are you sure you want to disable this pass code? It will no longer be valid for machine access.",
|
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "Are you sure you want to disable this pass code? It will no longer be valid for machine access.",
|
||||||
|
|||||||
@ -144,6 +144,7 @@
|
|||||||
"Are you sure you want to delete this product?": "この商品を削除してもよろしいですか?",
|
"Are you sure you want to delete this product?": "この商品を削除してもよろしいですか?",
|
||||||
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "この商品を削除してもよろしいですか?関連するすべての翻訳履歴データも削除されます。",
|
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "この商品を削除してもよろしいですか?関連するすべての翻訳履歴データも削除されます。",
|
||||||
"Are you sure you want to delete this role? This action cannot be undone.": "このロールを削除してもよろしいですか?取り消しはできません。",
|
"Are you sure you want to delete this role? This action cannot be undone.": "このロールを削除してもよろしいですか?取り消しはできません。",
|
||||||
|
"Are you sure you want to delete this staff card? This action cannot be undone.": "このスタッフカードを削除してもよろしいですか?この操作は取り消せません。",
|
||||||
"Are you sure you want to delete your account?": "アカウントを削除してもよろしいですか?",
|
"Are you sure you want to delete your account?": "アカウントを削除してもよろしいですか?",
|
||||||
"Are you sure you want to disable this advertisement?": "この広告を無効にしてもよろしいですか?",
|
"Are you sure you want to disable this advertisement?": "この広告を無効にしてもよろしいですか?",
|
||||||
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "このパスコードを無効にしてもよろしいですか?機器へのアクセスに使用できなくなります。",
|
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "このパスコードを無効にしてもよろしいですか?機器へのアクセスに使用できなくなります。",
|
||||||
|
|||||||
@ -144,6 +144,7 @@
|
|||||||
"Are you sure you want to delete this product?": "您確定要刪除此商品嗎?",
|
"Are you sure you want to delete this product?": "您確定要刪除此商品嗎?",
|
||||||
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "確定要刪除此商品嗎?所有相關的歷史翻譯數據也將被移除。",
|
"Are you sure you want to delete this product? All related historical translation data will also be removed.": "確定要刪除此商品嗎?所有相關的歷史翻譯數據也將被移除。",
|
||||||
"Are you sure you want to delete this role? This action cannot be undone.": "您確定要刪除此角色嗎?此操作將無法復原。",
|
"Are you sure you want to delete this role? This action cannot be undone.": "您確定要刪除此角色嗎?此操作將無法復原。",
|
||||||
|
"Are you sure you want to delete this staff card? This action cannot be undone.": "您確定要刪除此員工識別卡嗎?此操作將無法復原。",
|
||||||
"Are you sure you want to delete your account?": "您確定要刪除您的帳號嗎?",
|
"Are you sure you want to delete your account?": "您確定要刪除您的帳號嗎?",
|
||||||
"Are you sure you want to disable this advertisement?": "您確定要停用此廣告嗎?",
|
"Are you sure you want to disable this advertisement?": "您確定要停用此廣告嗎?",
|
||||||
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "您確定要停用此通行碼嗎?停用後將無法再用於機台存取。",
|
"Are you sure you want to disable this pass code? It will no longer be valid for machine access.": "您確定要停用此通行碼嗎?停用後將無法再用於機台存取。",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user