From 25b8c4438e80ce09a01279a9ff6500c277c73eb9 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 28 Oct 2017 06:20:44 -0700 Subject: [PATCH] Check for asset before attempting to cite mismatch --- ..._10_27_192423_migrate_denormed_asset_locations.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/database/migrations/2017_10_27_192423_migrate_denormed_asset_locations.php b/database/migrations/2017_10_27_192423_migrate_denormed_asset_locations.php index 45d5668a38..0d9f2c8cfd 100644 --- a/database/migrations/2017_10_27_192423_migrate_denormed_asset_locations.php +++ b/database/migrations/2017_10_27_192423_migrate_denormed_asset_locations.php @@ -67,15 +67,16 @@ class MigrateDenormedAssetLocations extends Migration $unassigned_assets=Asset::whereNull("location_id")->get(); foreach($unassigned_assets as $unassigned_asset) { - \Log::info('Asset: ".$unassigned_asset->id." still has no location'); + \Log::info('Asset: '.$unassigned_asset->id.' still has no location'); } - Asset::all()->each(function ($asset) { - if($asset->location_id != $asset->assetLoc()->id) { - \Log::info('MISMATCH MISMATCH '.$asset->id. "doesn't match its location"); + Asset::get()->each(function ($asset) { + if (($asset) && ($asset->location_id != $asset->assetLoc()->id)) { + \Log::info('MISMATCH MISMATCH '.$asset->id. "doesn't match its location"); } }); - + + die(); } /**