A free open source IT asset/license management system
Log fixes (#2972)
Daniel Meltzerb8cbf0022e1d
diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.phpindex 6febfd5f8e..acbe21b929 100755--- a/app/Http/Controllers/ViewAssetsController.php+++ b/app/Http/Controllers/ViewAssetsController.php@@ -379,6 +379,7 @@ class ViewAssetsController extends Controller}$logaction->target_id = $findlog->target_id;+ $logaction->target_type = User::class;$logaction->note = e(Input::get('note'));$logaction->updated_at = date("Y-m-d H:i:s");diff --git a/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php b/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.phpnew file mode 100644index 0000000000..c71d3b4e30--- /dev/null+++ b/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php@@ -0,0 +1,32 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\DB;++class AddMissingTargetTypeToLogsTable extends Migration+{+ /**+ * Run the migrations.+ *+ * @return void+ */+ public function up()+ {+ // Get list of action logs with a target id but not a target type. This fixes missing target_type in accept_asset+ DB::table('action_logs')->where('target_type', null)->where(function($query) {+ $query->where('action_type', 'accepted')+ ->orWhere('action_type', 'declined');+ })->update(['target_type'=> 'App\Models\User']);+ }++ /**+ * Reverse the migrations.+ *+ * @return void+ */+ public function down()+ {+ // Nothing to do.+ }+}diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.phpindex 2519168f21..27a4195740 100755--- a/resources/views/hardware/view.blade.php+++ b/resources/views/hardware/view.blade.php@@ -212,7 +212,7 @@</tr>@endif- @if ($asset->supplier_id)+ @if ($asset->supplier)<tr><td>{{ trans('admin/hardware/form.supplier') }}</td><td>@@ -615,7 +615,12 @@<del>{{ $log->target->showAssetName() }}</del>@endif@elseif (($log->action_type=='accepted') || ($log->action_type=='declined'))+ {{-- On a declined log, the asset isn't assigned to anyone when we look this up. --}}+ @if ($log->item->assigneduser){{ $log->item->assigneduser->fullName() }}+ @else+ Unknown+ @endif@elseDeleted User