mardi 4 décembre 2018

What do "except" and "idColumn" refers in "unique:table,column,except,idColumn"? from Laravel docs

To validate the update of the e-mail of a user already registered I have the next function to exclude the "unique" rule for the current User:

public function updateRules() {
    return [
        'name'  => 'required',
        'email' => 'required|unique:users,email,'.$this->id,
    ];
}

In the Laravel docs https://laravel.com/docs/5.7/validation#rule-unique I found the syntax unique:table,column,except,idColumn with 4 parameters:

  • table: refers to the table name "users"
  • column: refers the column name "email"
  • except: I'm taking it as the id of the Model instance I want to exclude from the "unique" verification
  • idColumn: I have no idea about this

Someone could clarify what do except and idColumn refers to?

Note for those obsessed with duplicate questions: I'm not asking how to do the rule exclusion for the update, because it seems to work just fine, I've read those questions and answers. I'm making helper functions and I need to know exactly what those two parameters means.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2PipgPv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire