how to check a field is exactly equal to a string or number
I want to check a field named course_id is equal a field of database id in course database. now I want to check if course_id is equal to id.
-
For details go ahead in documentation laravel.com/docs/5.2/validation#rule-existsAli– Ali2016-06-23 05:41:18 +00:00Commented Jun 23, 2016 at 5:41
Add a comment
|
2 Answers
You can validate it by using the exists validation rule:
$validationRules = ['course_id' => 'exists:course,id'];
Comments
create rule as below and use validator on input
$rules = array(
'id' => 'exists:your_table_name'
);
for more help https://laravel.com/docs/5.2/validation#rule-exists