mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 17:14:10 -08:00
934afa036f
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
289 lines
8.7 KiB
PHP
289 lines
8.7 KiB
PHP
<?php
|
|
|
|
namespace App\Presenters;
|
|
|
|
/**
|
|
* Class LicensePresenter
|
|
*/
|
|
class PredefinedKitPresenter extends Presenter
|
|
{
|
|
/**
|
|
* Json Column Layout for bootstrap table of kits
|
|
* @return string
|
|
*/
|
|
public static function dataTableLayout()
|
|
{
|
|
$layout = [
|
|
[
|
|
'field' => 'id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'name',
|
|
'searchable' => true,
|
|
'sortable' => true,
|
|
'title' => 'Name', // TODO: trans
|
|
'formatter' => 'kitsLinkFormatter',
|
|
],
|
|
];
|
|
|
|
$layout[] = [
|
|
'field' => 'checkincheckout',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => true,
|
|
'title' => trans('general.checkin').'/'.trans('general.checkout'),
|
|
'visible' => true,
|
|
'formatter' => 'kitsInOutFormatter',
|
|
];
|
|
|
|
$layout[] = [
|
|
'field' => 'actions',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => false,
|
|
'title' => trans('table.actions'),
|
|
'formatter' => 'kitsActionsFormatter',
|
|
];
|
|
|
|
return json_encode($layout);
|
|
}
|
|
|
|
/**
|
|
* Json Column Layout for bootstrap table of kit models
|
|
* @return string
|
|
*/
|
|
public static function dataTableModels()
|
|
{
|
|
$layout = [
|
|
[
|
|
'field' => 'id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'pivot_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'owner_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'name',
|
|
'searchable' => true,
|
|
'sortable' => true,
|
|
'title' => 'Name', // TODO: trans
|
|
'formatter' => 'modelsLinkFormatter',
|
|
], [
|
|
'field' => 'quantity',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'title' => 'Quantity', // TODO: trans
|
|
], [
|
|
'field' => 'actions',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => false,
|
|
'title' => trans('table.actions'),
|
|
'formatter' => 'kits_modelsActionsFormatter',
|
|
],
|
|
];
|
|
|
|
return json_encode($layout);
|
|
}
|
|
|
|
/**
|
|
* Json Column Layout for bootstrap table of kit licenses
|
|
* @return string
|
|
*/
|
|
public static function dataTableLicenses()
|
|
{
|
|
$layout = [
|
|
[
|
|
'field' => 'id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'pivot_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'owner_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'name',
|
|
'searchable' => true,
|
|
'sortable' => true,
|
|
'title' => 'Name', // TODO: trans
|
|
'formatter' => 'licensesLinkFormatter',
|
|
], [
|
|
'field' => 'quantity',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'title' => 'Quantity', // TODO: trans
|
|
], [
|
|
'field' => 'actions',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => false,
|
|
'title' => trans('table.actions'),
|
|
'formatter' => 'kits_licensesActionsFormatter',
|
|
],
|
|
];
|
|
|
|
return json_encode($layout);
|
|
}
|
|
|
|
/**
|
|
* Json Column Layout for bootstrap table of kit accessories
|
|
* @return string
|
|
*/
|
|
public static function dataTableAccessories()
|
|
{
|
|
$layout = [
|
|
[
|
|
'field' => 'id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'pivot_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'owner_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'name',
|
|
'searchable' => true,
|
|
'sortable' => true,
|
|
'title' => 'Name', // TODO: trans
|
|
'formatter' => 'accessoriesLinkFormatter',
|
|
], [
|
|
'field' => 'quantity',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'title' => 'Quantity', // TODO: trans
|
|
], [
|
|
'field' => 'actions',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => false,
|
|
'title' => trans('table.actions'),
|
|
'formatter' => 'kits_accessoriesActionsFormatter',
|
|
],
|
|
];
|
|
|
|
return json_encode($layout);
|
|
}
|
|
|
|
/**
|
|
* Json Column Layout for bootstrap table of kit consumables
|
|
* @return string
|
|
*/
|
|
public static function dataTableConsumables()
|
|
{
|
|
$layout = [
|
|
[
|
|
'field' => 'id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'pivot_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'owner_id',
|
|
'searchable' => false,
|
|
'sortable' => true,
|
|
'switchable' => true,
|
|
'title' => trans('general.id'),
|
|
'visible' => false,
|
|
], [
|
|
'field' => 'name',
|
|
'searchable' => true,
|
|
'sortable' => true,
|
|
'title' => 'Name', // TODO: trans
|
|
'formatter' => 'consumablesLinkFormatter',
|
|
], [
|
|
'field' => 'quantity',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'title' => 'Quantity', // TODO: trans
|
|
], [
|
|
'field' => 'actions',
|
|
'searchable' => false,
|
|
'sortable' => false,
|
|
'switchable' => false,
|
|
'title' => trans('table.actions'),
|
|
'formatter' => 'kits_consumablesActionsFormatter',
|
|
],
|
|
];
|
|
|
|
return json_encode($layout);
|
|
}
|
|
|
|
/**
|
|
* Link to this kit Name
|
|
* @return string
|
|
*/
|
|
public function nameUrl()
|
|
{
|
|
return (string) link_to_route('kits.show', $this->name, $this->id);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function fullName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* Url to view this item.
|
|
* @return string
|
|
*/
|
|
public function viewUrl()
|
|
{
|
|
return route('kits.show', $this->id);
|
|
}
|
|
}
|