jeudi 1 août 2019

How to custom validation unique multiple column in laravel

I have the contracts table with (id, name, company) And my rules:

public function rules()
{
    return [
        'name'    => 'required',
        'company' => 'required'
    ];
}

When I create

Contract one with id = 1, name = A, company = C

Contract two with id = 2, name = A, company = C. It's wrong.

Because I want a company cannot have the same contract name.

If contract two with id = 2, name = B, company = C. It's Okay.

So I want know how custom name and company fields to those two columns bind each other



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire