sdve
2 months ago
267
2
Laravel

error update model with unique field

Posted 2 months ago by sdve

Previously, validation worked for me, but now I don't know what happened when I try to update the unique field, it reports the following error.

"message": "Trying to get property of non-object",
"exception": "ErrorException",
"file": "/Applications/XAMPP/xamppfiles/htdocs/crimen/app/Http/Requests/UserUpdateRequest.php",
"line": 28,
"trace": [
    {
        "file": "/Applications/XAMPP/xamppfiles/htdocs/crimen/app/Http/Requests/UserUpdateRequest.php",
        "line": 28,
        "function": "handleError",
        "class": "Illuminate\Foundation\Bootstrap\HandleExceptions",
        "type": "->"
    },
{
	.....
}

My Validation:

public function rules()
{
    return [
        'name' => 'required|max:55',
        'email' => 'required|email|unique:users,email,'.$this->user,
        'sexo' => 'required|in:P,H,M',
        'nacimiento' => 'required|date',
    ];
}

Please sign in or create an account to participate in this conversation.