lundi 27 février 2017

Use unique validation for only specific record in database table in Laravel 5

I'm trying to validate unique question for specific book_id it means is should be unique only specific record.

table: questions

$title = this is question 1

$book_id = 12

TRUE = if question not posted for $book_id = 16, user can post same question.

Display Error = if question posted for $book_id = 12, user not able to post.

This is what I tried so far

"required|unique:questions,question,book_id".$book_id, "required|unique:questions,question,book_id,!".$book_id, "required|unique:questions,question,NULL,id,book_id,".!$book_id,



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire