1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00
invoiceninja/app/Ninja/Presenters/EntityPresenter.php

63 lines
1.4 KiB
PHP
Raw Normal View History

2016-05-23 11:26:08 +02:00
<?php namespace App\Ninja\Presenters;
2016-12-08 21:39:15 +01:00
use Utils;
2016-05-23 11:26:08 +02:00
use URL;
use Laracasts\Presenter\Presenter;
class EntityPresenter extends Presenter
{
/**
* @return string
*/
2016-05-23 11:26:08 +02:00
public function url()
{
2016-12-08 21:39:15 +01:00
$type = Utils::pluralizeEntityType($this->entity->getEntityType());
2016-05-23 11:26:08 +02:00
$id = $this->entity->public_id;
2016-12-08 21:39:15 +01:00
$link = sprintf('/%s/%s', $type, $id);
2016-05-23 11:26:08 +02:00
return URL::to($link);
}
2016-12-08 21:39:15 +01:00
public function editUrl()
{
return $this->url() . '/edit';
}
2016-10-18 16:55:07 +02:00
public function statusLabel()
{
$class = $text = '';
if ($this->entity->is_deleted) {
$class = 'danger';
$text = trans('texts.deleted');
} elseif ($this->entity->trashed()) {
$class = 'warning';
$text = trans('texts.archived');
} else {
//$class = 'success';
//$text = trans('texts.active');
}
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$text}</span>";
}
/**
* @return mixed
*/
2016-05-23 11:26:08 +02:00
public function link()
{
$name = $this->entity->getDisplayName();
$link = $this->url();
return link_to($link, $name)->toHtml();
}
2016-08-31 21:10:41 +02:00
public function titledName()
{
$entity = $this->entity;
$entityType = $entity->getEntityType();
return sprintf('%s: %s', trans('texts.' . $entityType), $entity->getDisplayName());
}
2016-05-23 11:26:08 +02:00
}