Try to fix: Invalid argument supplied for foreach.