laravel check between 2 integer from database

Ad

In database I have simple table as payment_setting with some column as id,min,max,... now I can use this below code to check between 2 integer:

'amount' => 'required|integer|between:1,10'

but I want to use payment_setting table to check between integers, like with:

'amount' => 'required|integer|between:payment_setting.min,payment_setting.max'

can I check validation like with that?

Ad

Answer

Ad

Try something like this:

$ps = DB::table('payment_settings')->where('id', $id)->first();
$rules = [
   'amount' => "required|integer|between:$ps->min,$ps->max"
];
Ad
source: stackoverflow.com
Ad