vendredi 1 février 2019

Constant expression contains invalid operations and Expression is not allowed as default value errors

I am using laravel 5.7 and I am trying to specify validation rules that when a user is updating their email the email must be unique BUT if its the same email for the current user ignore this rule. I am trying to pass the user id to the rule but its not working

The errors I am getting

Constant expression contains invalid operations

Expression is not allowed as default value

private $updateValidationRules =
 [
    'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,'."$this->id"],
    'name' => ['required', 'string', 'max:255'],
];

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire