AR
Size: a a a
AR
SG
SG
Rule::requiredIf()
и exists:tbl,col
? Суть Есть 2 типа заказа, на доставку и на самовывоз (pickup, delivery), если выбран самовывоз - то обязательно должна быть выбрана торговая точка и она должна существовать в базе, если же выбрана доставка то торговую точку указывать не обязательно, я пишу так:'shop_id' => [Но в данном случае даже если order_type === 'delivery', то
Rule::requiredId($request->input('order_type') === 'pickup'),
'exists:shops,id'
]
shop_id
проверяется на exists, как этого избежать?DM
SG
SG
SG
SG
DM
SG
SG
SG
SG
DM
DM
'shop_id' => Rule::requiredIf(function () use ($request) {
if ($request->input('type') === 'pickup') {
Rule::exists('shop', 'id');
return true;
};
return false;
})
SG
'shop_id' => Rule::requiredIf(function () use ($request) {
if ($request->input('type') === 'pickup') {
Rule::exists('shop', 'id');
return true;
};
return false;
})
$request->input('order_type') === 'pickup' ? 'required|exists:tbl,col' : 'nullable'
SG
SG
'shop_id' => Rule::requiredIf(function () use ($request) {
if ($request->input('type') === 'pickup') {
Rule::exists('shop', 'id');
return true;
};
return false;
})
['bail', Rule::requiredIf(...), 'exists:tbl,col']
DM
DM