2016-05-23 11:26:08 +02:00
|
|
|
<?php namespace App\Ninja\Presenters;
|
|
|
|
|
|
|
|
use URL;
|
|
|
|
use Laracasts\Presenter\Presenter;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
class EntityPresenter extends Presenter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-05-23 11:26:08 +02:00
|
|
|
public function url()
|
|
|
|
{
|
|
|
|
$type = $this->entity->getEntityType();
|
|
|
|
$id = $this->entity->public_id;
|
|
|
|
$link = sprintf('/%ss/%s', $type, $id);
|
|
|
|
|
|
|
|
return URL::to($link);
|
|
|
|
}
|
|
|
|
|
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>";
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
}
|