Reputation: 53
I have this rule:
Validator::make($data, [
'category' => [
'required',
Rule::notIn(['news', 'article']),
],
]);
The problem is that news and article are stored in another table. How do i pass the the data from that table into notIn instead?
Upvotes: 0
Views: 398
Reputation: 12391
use laravel exists
validation
ref link https://laravel.com/docs/8.x/validation#specifying-a-custom-column-name
Validator::make($data, [
'category' => [
'required',
Rule::exists('tableName')->where(function ($query) {
$query->where('column', "active ");
}),
],
]);
``
Upvotes: 1