lundi 7 novembre 2016

Laravel Unique validation for one record

I have a table table for providers in that i have to save provider id, code_id and rate. Here multiple providers have multiple code_id and provider have one code_id as unique, if he wants to save that code again validator has to say this provider has already this code id like that.

Here i want save values like below

**id     provider_id      code_id     rate**
   1           2            2         11.23 ....yes
   2           3            2         25.56 ....yes
   3           2            2         25.36 ....no 

How can add a validation for this.

Here is my code i have tried.

 $addProviderCptCodeRules = array(
            'provider_id'=>'required',
            'code_id'=>'required|table_name,code_id,'.$input['code_id'],
            'rate'=>'required',
        );

but it is not working.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire