mercredi 28 septembre 2016

Laravel5 - validation: ignore a given id for multiple uniqueness condition

I have created a validation form using Validator::make on laravel 5:

Validator::make($request->all(), [
            'title' => "unique:premieres,title,NULL,id,category_id,$category_id,datatype,$type"
        ]);

So this validation assure for an id that the title that had category_id = $category_id and datatype = $type in table "premieres" must exist only once,That work prefectly in INSERT query. However in UPDATE query i want to apply this validation but ignore it for this given id, i mean that the validation query must look for all other rows except this that i want to update. there is an example to how to do that in laravel official documentation Here in the part "Forcing A Unique Rule To Ignore A Given ID" but it doesn't work for this complexe query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire