From 583364f8c81c33009ff978c50e4b90b612013110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Fri, 8 Dec 2023 17:05:33 +0300 Subject: [PATCH] Added put method --- app/Http/Middleware/DateFormat.php | 2 +- app/Http/Middleware/Dropzone.php | 2 +- app/Http/Middleware/Money.php | 2 +- app/Http/Requests/Auth/User.php | 2 +- app/Http/Requests/Banking/Transaction.php | 2 +- app/Http/Requests/Common/Contact.php | 2 +- app/Http/Requests/Document/Document.php | 4 ++-- app/Http/Requests/Setting/Currency.php | 2 +- app/Http/Requests/Setting/Tax.php | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Http/Middleware/DateFormat.php b/app/Http/Middleware/DateFormat.php index f5d32e5bd..011a79176 100644 --- a/app/Http/Middleware/DateFormat.php +++ b/app/Http/Middleware/DateFormat.php @@ -18,7 +18,7 @@ class DateFormat */ public function handle($request, Closure $next) { - if (($request->method() == 'POST') || ($request->method() == 'PATCH')) { + if (in_array($request->method(), ['POST', 'PATCH', 'PUT'])) { $columns = new \stdClass(); $columns->fields = [ 'paid_at', diff --git a/app/Http/Middleware/Dropzone.php b/app/Http/Middleware/Dropzone.php index 83fd056da..645635001 100644 --- a/app/Http/Middleware/Dropzone.php +++ b/app/Http/Middleware/Dropzone.php @@ -16,7 +16,7 @@ class Dropzone */ public function handle($request, Closure $next) { - if (! in_array($request->method(), ['POST', 'PATCH'])) { + if (! in_array($request->method(), ['POST', 'PATCH', 'PUT'])) { return $next($request); } diff --git a/app/Http/Middleware/Money.php b/app/Http/Middleware/Money.php index dc67b36bc..f4a1924b0 100644 --- a/app/Http/Middleware/Money.php +++ b/app/Http/Middleware/Money.php @@ -19,7 +19,7 @@ class Money */ public function handle($request, Closure $next) { - if (($request->method() != 'POST') && ($request->method() != 'PATCH')) { + if (! in_array($request->method(), ['POST', 'PATCH', 'PUT'])) { return $next($request); } diff --git a/app/Http/Requests/Auth/User.php b/app/Http/Requests/Auth/User.php index 521d7f8cf..39c751f48 100644 --- a/app/Http/Requests/Auth/User.php +++ b/app/Http/Requests/Auth/User.php @@ -34,7 +34,7 @@ class User extends FormRequest $email = 'required|email:rfc,dns'; - if ($this->getMethod() == 'PATCH') { + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { // Updating user if (is_numeric($this->user)) { $id = $this->user; diff --git a/app/Http/Requests/Banking/Transaction.php b/app/Http/Requests/Banking/Transaction.php index 6473e0740..c9cde4231 100644 --- a/app/Http/Requests/Banking/Transaction.php +++ b/app/Http/Requests/Banking/Transaction.php @@ -20,7 +20,7 @@ class Transaction extends FormRequest $type = config('type.transaction.' . $type . '.route.parameter'); // Check if store or update - if ($this->getMethod() == 'PATCH') { + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { $model = $this->isApi() ? 'transaction' : $type; $id = is_numeric($this->$model) ? $this->$model : $this->{$model}->getAttribute('id'); diff --git a/app/Http/Requests/Common/Contact.php b/app/Http/Requests/Common/Contact.php index ac8a01f23..f4ac52eba 100644 --- a/app/Http/Requests/Common/Contact.php +++ b/app/Http/Requests/Common/Contact.php @@ -26,7 +26,7 @@ class Contact extends FormRequest $company_id = (int) $this->request->get('company_id'); // Check if store or update - if ($this->getMethod() == 'PATCH') { + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { $model = $this->isApi() ? 'contact' : $type; $id = is_numeric($this->$model) ? $this->$model : $this->$model->getAttribute('id'); diff --git a/app/Http/Requests/Document/Document.php b/app/Http/Requests/Document/Document.php index dc4d4667c..9b89e9b14 100644 --- a/app/Http/Requests/Document/Document.php +++ b/app/Http/Requests/Document/Document.php @@ -25,8 +25,8 @@ class Document extends FormRequest $type = config('type.document.' . $type . '.route.parameter'); - // Check if store or update - if ($this->getMethod() == 'PATCH') { + // Check if store or update. Todo: check if this is the best way to do this + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { $model = $this->isApi() ? 'document' : $type; $id = is_numeric($this->$model) ? $this->$model : $this->{$model}->getAttribute('id'); diff --git a/app/Http/Requests/Setting/Currency.php b/app/Http/Requests/Setting/Currency.php index f52227103..5e0319a14 100644 --- a/app/Http/Requests/Setting/Currency.php +++ b/app/Http/Requests/Setting/Currency.php @@ -14,7 +14,7 @@ class Currency extends FormRequest public function rules() { // Check if store or update - if ($this->getMethod() == 'PATCH') { + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { $id = is_numeric($this->currency) ? $this->currency : $this->currency->getAttribute('id'); } else { $id = null; diff --git a/app/Http/Requests/Setting/Tax.php b/app/Http/Requests/Setting/Tax.php index 7f257a4b3..aa31098cc 100644 --- a/app/Http/Requests/Setting/Tax.php +++ b/app/Http/Requests/Setting/Tax.php @@ -14,7 +14,7 @@ class Tax extends FormRequest public function rules() { // Check if store or update - if ($this->getMethod() == 'PATCH') { + if (in_array($this->getMethod(), ['PATCH', 'PUT'])) { $id = is_numeric($this->tax) ? $this->tax : $this->tax->getAttribute('id'); $enabled = 'integer|boolean'; } else {