I would like to put a condition in my store function so that if domain_type=1 then payment_proof is null, otherwise we put a value to payment_proof.
public function update(Request $request, $id)
{
$request->validate([
'command_number' => 'required',
'domain_type' => 'required',
'payment_proof' => ['nullable', 'required_if:domain_type:2,3']
]);
$form = Form::find($id);
$form->command_number = $request->command_number;
$form->domain_type = $request->domain_type;
$form->payment_proof = $request->payment_proof;
$form->save();
return redirect()->route('forms.index')
return redirect()->route('forms.index')
}
if()
statement, or aternary
, likeif ($request->domain_type == 1) { $form->payment_proff = $request->payment_proof; }
, or$form->payment_proof = $request->domain_type == 1 ? $request->payment_proof : null;
... This is pretty basic though; was there a specific issue you had? – Tim Lewis