@bgweb can you try ->get()[0] instead of first()?
first() method returning null values
I currently have a function that is returning an ID to collect the appropriate information for a vehicle. I am using the first() method to collect the first record that the function finds. However, it is pulling in rows where the ID doesn't exist. I've been wracking my brain researching this to find that best way to continue to pull the first record that is not null. Any ideas would be appreciated.
public function getVehicleToEngineConfigIdAttribute() { $vehicleToEngineConfig = Db::connection('vcdb') ->table('VehicleToEngineConfig') ->where('VehicleID', $this->vehicle_id) ->where('EngineConfigID', $this->engine_config_id) ->first();
return $vehicleToEngineConfig->VehicleToEngineConfigID;
}
Please or to participate in this conversation.