Added count of assets in asset models table

This commit is contained in:
snipe
2013-11-18 01:32:22 -05:00
parent 2fd8b1760c
commit 524d3d233d
3 changed files with 19 additions and 6 deletions
+1
View File
@@ -5,5 +5,6 @@ return array(
'title' => 'Asset Model Name',
'modelnumber' => 'Model No.',
'created_at' => 'Created at',
'numassets' => 'Assets',
);
+10 -4
View File
@@ -2,9 +2,15 @@
class Model extends Elegant {
// Declare the rules for the form validation
protected $rules = array(
'name' => 'required|min:3',
);
// Declare the rules for the form validation
protected $rules = array(
'name' => 'required|min:3',
);
public function assets()
{
return $this->hasMany('Asset', 'model_id');
}
}
+8 -2
View File
@@ -24,7 +24,8 @@ Asset Models ::
<thead>
<tr>
<th class="span6">@lang('admin/models/table.title')</th>
<th class="span2">@lang('admin/models/table.modelnumber')</th>
<th class="span4">@lang('admin/models/table.modelnumber')</th>
<th class="span1">@lang('admin/models/table.numassets')</th>
<th class="span2">@lang('admin/models/table.created_at')</th>
<th class="span2">@lang('table.actions')</th>
</tr>
@@ -32,8 +33,13 @@ Asset Models ::
<tbody>
@foreach ($models as $model)
<tr>
<td>{{ $model->name }}</td>
<td>{{ $model->name }}
</td>
<td>{{ $model->modelno }}</td>
<td>{{ ($model->assets->count()) }}</td>
<td>{{ $model->created_at->diffForHumans() }}</td>
<td>
<a href="{{ route('update/model', $model->id) }}" class="btn btn-mini">@lang('button.edit')</a>