2016-12-23 17:52:00 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class LocationPresenter
|
|
|
|
* @package App\Presenters
|
|
|
|
*/
|
|
|
|
class LocationPresenter extends Presenter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* JSON representation of this location for data table.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function forDataTable()
|
|
|
|
{
|
|
|
|
$actions = '<nobr>';
|
|
|
|
$actions .= Helper::generateDatatableButton('edit', route('locations.edit', $this->id));
|
|
|
|
$actions .= Helper::generateDatatableButton(
|
|
|
|
'delete',
|
|
|
|
route('locations.destroy', $this->id),
|
|
|
|
true, /*enabled*/
|
|
|
|
trans('admin/locations/message.delete.confirm'),
|
|
|
|
$this->name
|
|
|
|
);
|
|
|
|
$actions .= '</nobr>';
|
|
|
|
|
|
|
|
$results = [
|
2016-12-23 19:23:07 -08:00
|
|
|
'actions' => $actions,
|
|
|
|
'address' => $this->address,
|
2016-12-23 17:52:00 -08:00
|
|
|
'assets_checkedout' => $this->model->assets()->count(),
|
2016-12-23 19:23:07 -08:00
|
|
|
'assets_default' => $this->model->assignedassets()->count(),
|
|
|
|
'city' => $this->city,
|
|
|
|
'country' => $this->country,
|
|
|
|
'currency' => $this->currency,
|
|
|
|
'id' => $this->id,
|
|
|
|
'name' => $this->nameUrl(),
|
|
|
|
'parent' => ($this->model->parent) ? $this->model->parent->present()->nameUrl() : '',
|
|
|
|
'state' => $this->state,
|
|
|
|
'zip' => $this->zip,
|
|
|
|
// 'assets' => ($this->assets->count() + $this->assignedassets->count()),
|
2016-12-23 17:52:00 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Link to this locations name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function nameUrl()
|
|
|
|
{
|
|
|
|
return (string)link_to_route('locations.show', $this->name, $this->id);
|
|
|
|
}
|
|
|
|
}
|