I'm trying to validate unique title 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 = 12
, 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,
I think because you're trying to look up the database to see if a question has been posted for $book_id = 12 that you might want to take a look at the Exist(Database) validation method.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community