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; }