Skip to content

Commit

Permalink
Asset counter for #759 (needs more work)
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed May 4, 2015
1 parent f463cd6 commit c487bee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/config/version.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
return array (
'app_version' => 'v1.2.7-2',
'hash_version' => 'v1.2.7-2-gc8870dd',
'app_version' => 'v1.2.7-3',
'hash_version' => 'v1.2.7-3-g5e7a4e8',
);
4 changes: 2 additions & 2 deletions app/controllers/admin/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LocationsController extends AdminController
public function getIndex()
{
// Grab all the locations
$locations = Location::orderBy('created_at', 'DESC')->with('parent')->get();
$locations = Location::orderBy('created_at', 'DESC')->with('parent','assets')->get();

// Show the page
return View::make('backend/locations/index', compact('locations'));
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getDelete($locationId)
}


if ($location->has_users() > 0) {
if ($location->has_users->count() > 0) {
return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.assoc_users'));
} elseif ($location->childLocations->count() > 0) {
return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.assoc_users'));
Expand Down
6 changes: 5 additions & 1 deletion app/models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class Location extends Elegant
);

public function has_users() {
return $this->hasMany('User', 'location_id')->count();
return $this->hasMany('User', 'location_id');
}

public function assets() {
return $this->hasMany('Actionlog','location_id');
}

public function parent() {
Expand Down
5 changes: 4 additions & 1 deletion app/views/backend/locations/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<tr role="row">
<th class="col-md-2">@lang('admin/locations/table.name')</th>
<th class="col-md-2">@lang('admin/locations/table.parent')</th>
<th class="col-md-3">@lang('admin/locations/table.assets')</th>
<th class="col-md-3">@lang('admin/locations/table.address')</th>
<th class="col-md-2">@lang('admin/locations/table.city'),
@lang('admin/locations/table.state')
Expand All @@ -33,11 +34,13 @@
<tbody>
@foreach ($locations as $location)
<tr>
<td>{{{ $location->name }}}</td><td>
<td>{{{ $location->name }}}</td>
<td>
@if ($location->parent)
{{{ $location->parent->name }}}
@endif
</td>
<td>{{{ $location->assets->count() }}}</td>
<td>{{{ $location->address }}}
@if($location->address2 != '')
, {{{ $location->address2 }}}
Expand Down

0 comments on commit c487bee

Please sign in to comment.