2016-12-23 17:52:00 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class LicensePresenter
|
|
|
|
* @package App\Presenters
|
|
|
|
*/
|
|
|
|
class LicensePresenter extends Presenter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* JSON representation of this license for data table.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function forDataTable()
|
|
|
|
{
|
|
|
|
$actions = '<span style="white-space: nowrap;">';
|
|
|
|
|
|
|
|
if (Gate::allows('checkout', License::class)) {
|
|
|
|
$actions .= Helper::generateDatatableButton(
|
|
|
|
'checkout',
|
|
|
|
route('licenses.freecheckout', $this->id),
|
|
|
|
$this->remaincount() > 0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Gate::allows('create', $this->model)) {
|
|
|
|
$actions .= Helper::generateDatatableButton('clone', route('clone/license', $this->id));
|
|
|
|
}
|
|
|
|
if (Gate::allows('update', $this->model)) {
|
|
|
|
$actions .= Helper::generateDatatableButton('edit', route('licenses.edit', $this->id));
|
|
|
|
}
|
|
|
|
if (Gate::allows('delete', $this->model)) {
|
|
|
|
$actions .= Helper::generateDatatableButton(
|
|
|
|
'delete',
|
|
|
|
route('licenses.destroy', $this->id),
|
|
|
|
true, /*enabled*/
|
|
|
|
trans('admin/licenses/message.delete.confirm'),
|
|
|
|
$this->name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$actions .='</span>';
|
|
|
|
|
|
|
|
$results = [
|
2016-12-23 19:23:07 -08:00
|
|
|
'actions' => $actions,
|
|
|
|
'company' => $this->companyUrl(),
|
|
|
|
'expiration_date' => $this->expiration_date,
|
2016-12-23 17:52:00 -08:00
|
|
|
'id' => $this->id,
|
2016-12-23 19:23:07 -08:00
|
|
|
'license_email' => $this->license_email,
|
|
|
|
'license_name' => $this->license_name,
|
|
|
|
'manufacturer' => $this->manufacturerUrl(),
|
2016-12-23 17:52:00 -08:00
|
|
|
'name' => $this->nameUrl(),
|
2016-12-23 19:23:07 -08:00
|
|
|
'notes' => $this->notes,
|
|
|
|
'order_number' => $this->order_number,
|
|
|
|
'purchase_cost' => Helper::formatCurrencyOutput($this->purchase_cost),
|
|
|
|
'purchase_date' => $this->purchase_date,
|
|
|
|
'purchase_order' => $this->purchase_order,
|
|
|
|
'remaining' => $this->remaincount(),
|
2016-12-23 17:52:00 -08:00
|
|
|
'serial' => $this->serialUrl(),
|
|
|
|
'totalSeats' => $this->model->licenseSeatsCount,
|
|
|
|
];
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Link to this licenses Name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function nameUrl()
|
|
|
|
{
|
|
|
|
return (string)link_to_route('licenses.show', $this->name, $this->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Link to this licenses serial
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function serialUrl()
|
|
|
|
{
|
|
|
|
return (string) link_to('/licenses/'.$this->id, mb_strimwidth($this->serial, 0, 50, "..."));
|
|
|
|
}
|
2016-12-26 15:19:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Url to view this item.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function viewUrl()
|
|
|
|
{
|
|
|
|
return route('licenses.show', $this->id);
|
|
|
|
}
|
2016-12-23 17:52:00 -08:00
|
|
|
}
|