Contact and Document update request fixed on Api

This commit is contained in:
Cüneyt Şentürk 2021-02-17 21:01:41 +03:00
parent ddc08ddcb2
commit 043af4a602
2 changed files with 14 additions and 3 deletions

View File

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

View File

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