From 043af4a60245edf602fee7f18893b339ae9e044f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 17 Feb 2021 21:01:41 +0300 Subject: [PATCH] Contact and Document update request fixed on Api --- app/Http/Requests/Common/Contact.php | 9 +++++++-- app/Http/Requests/Document/Document.php | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Http/Requests/Common/Contact.php b/app/Http/Requests/Common/Contact.php index b69cce146..200783ca8 100644 --- a/app/Http/Requests/Common/Contact.php +++ b/app/Http/Requests/Common/Contact.php @@ -23,7 +23,6 @@ class Contact extends FormRequest */ public function rules() { - $email = ''; $required = ''; @@ -32,7 +31,13 @@ class Contact extends FormRequest // Check if store or update if ($this->getMethod() == 'PATCH') { - $id = is_numeric($this->$type) ? $this->$type : $this->$type->getAttribute('id'); + $model = $type; + + if ($this->isApi()) { + $model = 'contact'; + } + + $id = is_numeric($this->$model) ? $this->$model : $this->$model->getAttribute('id'); } else { $id = null; } diff --git a/app/Http/Requests/Document/Document.php b/app/Http/Requests/Document/Document.php index a82fa3f00..ded651f33 100644 --- a/app/Http/Requests/Document/Document.php +++ b/app/Http/Requests/Document/Document.php @@ -32,7 +32,13 @@ class Document extends FormRequest // Check if store or update if ($this->getMethod() == 'PATCH') { - $id = is_numeric($this->$type) ? $this->$type : $this->{$type}->getAttribute('id'); + $model = $type; + + if ($this->isApi()) { + $model = 'document'; + } + + $id = is_numeric($this->$model) ? $this->$model : $this->{$model}->getAttribute('id'); } else { $id = null; }