diff --git a/app/Models/Location.php b/app/Models/Location.php index 37348bd4a..c524c1eb3 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -54,7 +54,7 @@ class Location extends SnipeModel public function assets() { - return $this->hasManyThrough('\App\Models\Asset', '\App\Models\User', 'location_id', 'assigned_to', 'id'); + return $this->hasManyThrough('\App\Models\Asset', '\App\Models\User', 'location_id', 'assigned_to', 'id')->where("assets.assigned_type",User::class); } public function locationAssets() diff --git a/database/migrations/2017_10_20_234129_add_location_indices_to_assets.php b/database/migrations/2017_10_20_234129_add_location_indices_to_assets.php new file mode 100644 index 000000000..eb36933f6 --- /dev/null +++ b/database/migrations/2017_10_20_234129_add_location_indices_to_assets.php @@ -0,0 +1,35 @@ +index('rtd_location_id'); + $table->index(['assigned_type','assigned_to']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('assets', function (Blueprint $table) { + // + $table->dropIndex(['rtd_location_id']); + $table->dropIndex(['assigned_type','assigned_to']); + }); + } +} diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index d30dd16c8..37077f908 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -379,16 +379,16 @@