mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
61543f3a04
* Add presenters for models. Move bootstrap table JSON generation to these presenters, which cleans up controllers a lot. Move view specific modifications from the models to the presenters as well. * Fix some issues found by travis and codacy * Fix a few more issues found while testing. * Attempt another acceptance test fix * Try something else * Maybe..
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?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 = [
|
|
'id' => $this->id,
|
|
'name' => $this->nameUrl(),
|
|
'assets' => $this->assets()->count(),
|
|
'licenses' => $this->licenses()->count(),
|
|
'accessories' => $this->accessories()->count(),
|
|
'consumables' => $this->consumables()->count(),
|
|
'actions' => $actions
|
|
];
|
|
|
|
return $results;
|
|
}
|
|
|
|
/**
|
|
* Link to this manufacturers name
|
|
* @return string
|
|
*/
|
|
public function nameUrl()
|
|
{
|
|
return (string) link_to_route('manufacturers.show', $this->name, $this->id);
|
|
}
|
|
}
|