vendredi 1 avril 2016

Validate whether multiple fields are unique simultaneously in laravel 5 using request class

This my request class rules.

return [
        'title' => 'required|unique:event_cals,title',
        'eventDate' => 'required|date|after:yesterday',
        'venue' => 'required',
        'time' => 'required',
        'type' => 'required',
        'event_date' => 'unique:event_cals,event_date,NULL,id,venue,{$request->venue},time,{$request->time}'
    ];

There I need to clarify the last rule. It is not working. There I need to check if there any row without same eventDate, venue and time altogether. Simply, There can't be any events with same values for all the eventDate, time and venue.

Below is the db. enter image description here

I need to avoid entering such rows because above I mentioned three fields values are equal. Above request class final rule is my attempt for that. Please can anybody knows to solve that problem



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire