mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Log fixes (#2972)
* Make sure we set target_type when creating an accept asset log, and add a migration to fix older ones. * On a declined log, we don't have an assigned user. Guard against this conditional (which realistically should never be hit?) Should fix #2940 * Fix codacy issues with migration.
This commit is contained in:
parent
dd3718489a
commit
b8cbf0022e
|
@ -379,6 +379,7 @@ class ViewAssetsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$logaction->target_id = $findlog->target_id;
|
$logaction->target_id = $findlog->target_id;
|
||||||
|
$logaction->target_type = User::class;
|
||||||
$logaction->note = e(Input::get('note'));
|
$logaction->note = e(Input::get('note'));
|
||||||
$logaction->updated_at = date("Y-m-d H:i:s");
|
$logaction->updated_at = date("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
}
|
||||||
|
}
|
|
@ -212,7 +212,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($asset->supplier_id)
|
@if ($asset->supplier)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ trans('admin/hardware/form.supplier') }}</td>
|
<td>{{ trans('admin/hardware/form.supplier') }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -615,7 +615,12 @@
|
||||||
<del>{{ $log->target->showAssetName() }}</del>
|
<del>{{ $log->target->showAssetName() }}</del>
|
||||||
@endif
|
@endif
|
||||||
@elseif (($log->action_type=='accepted') || ($log->action_type=='declined'))
|
@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() }}
|
{{ $log->item->assigneduser->fullName() }}
|
||||||
|
@else
|
||||||
|
Unknown
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
|
|
||||||
Deleted User
|
Deleted User
|
||||||
|
|
Loading…
Reference in a new issue