Reputation: 327
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
.
Upvotes: 0
Views: 2019
Reputation: 2023
You can validate it by using the exists validation rule:
$validationRules = ['course_id' => 'exists:course,id'];
Upvotes: 1
Reputation: 1129
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
Upvotes: 0