2016-12-23 17:52:00 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ManufacturerPresenter
|
|
|
|
* @package App\Presenters
|
|
|
|
*/
|
|
|
|
class ManufacturerPresenter extends Presenter
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* JSON representation of this manufacturer for data table.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function forDataTable()
|
|
|
|
{
|
|
|
|
$actions = '<nobr>';
|
|
|
|
$actions .= Helper::generateDatatableButton('edit', route('manufacturers.edit', $this->id));
|
|
|
|
$actions .= Helper::generateDatatableButton(
|
|
|
|
'delete',
|
|
|
|
route('manufacturers.destroy', $this->id),
|
|
|
|
true, /*enabled*/
|
|
|
|
trans('admin/manufacturers/message.delete.confirm'),
|
|
|
|
$this->name
|
|
|
|
);
|
|
|
|
$actions .= '</nobr>';
|
|
|
|
|
|
|
|
$results = [
|
|
|
|
'accessories' => $this->accessories()->count(),
|
2016-12-23 19:23:07 -08:00
|
|
|
'actions' => $actions,
|
|
|
|
'assets' => $this->assets()->count(),
|
2016-12-23 17:52:00 -08:00
|
|
|
'consumables' => $this->consumables()->count(),
|
2016-12-23 19:23:07 -08:00
|
|
|
'id' => $this->id,
|
|
|
|
'licenses' => $this->licenses()->count(),
|
|
|
|
'name' => $this->nameUrl(),
|
2016-12-23 17:52:00 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Link to this manufacturers name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function nameUrl()
|
|
|
|
{
|
2016-12-29 14:02:18 -08:00
|
|
|
return (string) link_to_route('manufacturers.show', $this->name, $this->id);
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|
2016-12-26 15:19:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Url to view this item.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function viewUrl()
|
|
|
|
{
|
|
|
|
return route('manufacturers.show', $this->id);
|
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|