Yes, you can concatenate a model depending upon the condition. Below, I have added a workable code to implement.
Import both model.
//use App\Car;
//use App\Train;
$isCar = true; // boolean condition to check whether it is a car or train
$classVariable = null;
if ($variable) {
$classVariable = new Car();
}else{
$classVariable = new Train();
}
$result = $classVariable->where('model', $value)->get();
//this will provide you a car model query
dd($result);
Better Approach
A better approach will be to use a Vehicle model and Vehicle Type.
Add a vehicle_type_id in the vehicles table.
So whenever you need to retrieve car types, you can use
//Suppose vehicle_type_id for car is 1
$carVehicle = Vehicle::where('vehicle_type_id', 1)->get();
//Suppose vehicle_type_id for train is 2
$trainVehicle = Vehicle::where('vehicle_type_id', 2)->get();
useafter namespace declaration.