Added qty to asset components - fixed #4876

This commit is contained in:
snipe 2018-01-24 05:25:01 -08:00
parent fefd6d60f6
commit 543ea28b72
2 changed files with 12 additions and 2 deletions

View file

@ -223,7 +223,7 @@ class Asset extends Depreciable
*/
public function components()
{
return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id')->withTrashed();
return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id', 'assigned_qty')->withTrashed();
}
/**

View file

@ -542,12 +542,22 @@
<div class="col-md-12">
@if(count($asset->components) > 0)
<table class="table table-striped">
<thead>
<th>{{ trans('general.name') }}</th>
<th>{{ trans('general.qty') }}</th>
<th>{{ trans('general.purchase_cost') }}</th>
</thead>
<tbody>
<?php $totalCost = 0; ?>
@foreach ($asset->components as $component)
@if (is_null($component->deleted_at))
<tr>
<td><a href="{{ route('components.show', $component->id) }}">{{ $component->name }}</a></td>
<td>
<a href="{{ route('components.show', $component->id) }}">{{ $component->name }}</a>
</td>
<td>{{ $component->pivot->assigned_qty }}</td>
<td>{{ $component->purchase_cost }}</td>
</tr>
@endif
@endforeach