you just need the name of your dropdown and then can check if it is set or not.
if(isset($request->downDownFieldName)) {
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi there, I hope I can get some help. I am new to Laravel and PHP and loving it more daily. I have a small issue, how can I write an IF statement to check if a dropdown has a selected value? If it does, code must execute in a way else in a different way.
Here is my controller (i want something in the if like this between ??):
public function runCommand(Request $request){
$user = User::select("id", "email")->first();
$signature = $request->input('signature');
if (??dropdown is selected??){
$command = Artisan::call($signature, ['user' => $user->email]);
}else{
$command = Artisan::call($signature);
}
return response($command);
}
Please or to participate in this conversation.