diff --git a/app/Enums/ActionType.php b/app/Enums/ActionType.php new file mode 100644 index 0000000000..6798a6b78e --- /dev/null +++ b/app/Enums/ActionType.php @@ -0,0 +1,33 @@ +isRequestedBy($user)) || $cancel_by_admin) { $item->cancelRequest($requestingUser); $data['item_quantity'] = ($item_request) ? $item_request->qty : 1; - $logaction->logaction('request_canceled'); + $logaction->logaction(ActionType::RequestCanceled); if (($settings->alert_email != '') && ($settings->alerts_enabled == '1') && (! config('app.lock_passwords'))) { $settings->notify(new RequestAssetCancelation($data)); diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index 786246778c..4a12835a9d 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -9,6 +9,7 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str; +use App\Enums\ActionType; /** * Model for the Actionlog (the table that keeps a historical log of @@ -335,9 +336,12 @@ class Actionlog extends SnipeModel * @since [v3.0] * @return bool */ - public function logaction($actiontype) + public function logaction(string|ActionType $actiontype) { - $this->action_type = $actiontype; + if (is_string($actiontype)) { + $actiontype = ActionType::from($actiontype); + } + $this->action_type = $actiontype->value; $this->remote_ip = request()->ip(); $this->user_agent = request()->header('User-Agent'); $this->action_source = $this->determineActionSource(); diff --git a/app/Presenters/ActionlogPresenter.php b/app/Presenters/ActionlogPresenter.php index 0f82d1f667..a2dc75113d 100644 --- a/app/Presenters/ActionlogPresenter.php +++ b/app/Presenters/ActionlogPresenter.php @@ -102,7 +102,7 @@ class ActionlogPresenter extends Presenter return 'fa-solid fa-rotate-right'; } - if ($this->action_type == 'note_added') { + if ($this->action_type == 'note added') { return 'fas fa-sticky-note'; }