From b7e818230937e71184bbca14be285d2528543a0a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 11 May 2026 10:41:13 +0530 Subject: [PATCH] Updated 'updated_by' column value on every change --- .../CharacteristicApprovalController.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/Http/Controllers/CharacteristicApprovalController.php b/app/Http/Controllers/CharacteristicApprovalController.php index 4553f17..7a5fb3e 100644 --- a/app/Http/Controllers/CharacteristicApprovalController.php +++ b/app/Http/Controllers/CharacteristicApprovalController.php @@ -2,10 +2,12 @@ namespace App\Http\Controllers; +use App\Models\CharacteristicApproverMaster; use App\Models\ClassCharacteristic; use App\Models\RequestCharacteristic; use Carbon\Carbon; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; class CharacteristicApprovalController extends Controller { @@ -358,10 +360,26 @@ class CharacteristicApprovalController extends Controller ->where('work_flow_id', $record->work_flow_id) ->get(); + $approverMasterNames = CharacteristicApproverMaster::find($record->characteristic_approver_master_id); + + if (! $approverMasterNames) { + abort(500, 'Approver master not found'); + } + + $approverNameColumn = match ($level) { + 1 => 'name1', + 2 => 'name2', + 3 => 'name3', + default => null, + }; + + $updatedBy = $approverNameColumn ? $approverMasterNames->$approverNameColumn : null; + $updateData = [ $statusColumn => $status, $remarkColumn => $request->input('remark'), $approvedAtColumn => Carbon::now(), + 'updated_by' => $updatedBy, ]; if (in_array($status, ['Approved', 'Rejected'])) { @@ -386,6 +404,14 @@ class CharacteristicApprovalController extends Controller // ->where('aufnr', $record->aufnr) // ->update(['has_work_flow_id' => $record->work_flow_id]); + if ($status == 'Rejected') { + $filePath = 'uploads/LaserDocs/'.$record->work_flow_id.'.png'; + + if (Storage::disk('local')->exists($filePath)) { + Storage::disk('local')->delete($filePath); + } + } + if ($returnView) { return match ($status) { 'Approved' => view('approval.success'),