mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Implemented base entity presenter
This commit is contained in:
parent
260b9212b9
commit
4b1b80886d
@ -2,9 +2,8 @@
|
||||
|
||||
use URL;
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class ClientPresenter extends Presenter {
|
||||
class ClientPresenter extends EntityPresenter {
|
||||
|
||||
public function country()
|
||||
{
|
||||
@ -28,14 +27,4 @@ class ClientPresenter extends Presenter {
|
||||
|
||||
return "<span class=\"label label-{$class}\">{$text}</span>";
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
return URL::to('/clients/' . $this->entity->public_id);
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
return link_to('/clients/' . $this->entity->public_id, $this->entity->getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class CreditPresenter extends Presenter {
|
||||
class CreditPresenter extends EntityPresenter {
|
||||
|
||||
public function client()
|
||||
{
|
||||
@ -14,4 +13,4 @@ class CreditPresenter extends Presenter {
|
||||
{
|
||||
return Utils::fromSqlDate($this->entity->credit_date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
25
app/Ninja/Presenters/EntityPresenter.php
Normal file
25
app/Ninja/Presenters/EntityPresenter.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use URL;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class EntityPresenter extends Presenter {
|
||||
|
||||
public function url()
|
||||
{
|
||||
$type = $this->entity->getEntityType();
|
||||
$id = $this->entity->public_id;
|
||||
$link = sprintf('/%ss/%s', $type, $id);
|
||||
|
||||
return URL::to($link);
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
$name = $this->entity->getDisplayName();
|
||||
$link = $this->url();
|
||||
|
||||
return link_to($link, $name)->toHtml();
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class ExpensePresenter extends Presenter {
|
||||
class ExpensePresenter extends EntityPresenter {
|
||||
|
||||
// Expenses
|
||||
public function vendor()
|
||||
@ -20,9 +19,5 @@ class ExpensePresenter extends Presenter {
|
||||
{
|
||||
return $this->entity->invoice_id ? $this->entity->convertedAmount() : 0;
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
return link_to('/expenses/' . $this->entity->public_id, $this->entity->name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use URL;
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class InvoicePresenter extends Presenter {
|
||||
class InvoicePresenter extends EntityPresenter {
|
||||
|
||||
public function client()
|
||||
{
|
||||
@ -69,16 +68,6 @@ class InvoicePresenter extends Presenter {
|
||||
return $this->entity->frequency ? $this->entity->frequency->name : '';
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
return URL::to('/invoices/' . $this->entity->public_id);
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
return link_to('/invoices/' . $this->entity->public_id, $this->entity->invoice_number);
|
||||
}
|
||||
|
||||
public function email()
|
||||
{
|
||||
$client = $this->entity->client;
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use URL;
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class PaymentPresenter extends Presenter {
|
||||
class PaymentPresenter extends EntityPresenter {
|
||||
|
||||
public function client()
|
||||
{
|
||||
@ -25,14 +24,4 @@ class PaymentPresenter extends Presenter {
|
||||
}
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
return URL::to('/payments/' . $this->entity->public_id . '/edit');
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
return link_to('/payments/' . $this->entity->public_id . '/edit', $this->entity->getDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class TaskPresenter extends Presenter {
|
||||
class TaskPresenter extends EntityPresenter {
|
||||
|
||||
public function client()
|
||||
{
|
||||
@ -55,4 +52,4 @@ class TaskPresenter extends Presenter {
|
||||
return "<span class=\"label label-{$class}\">{$text}</span>";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use Utils;
|
||||
use Laracasts\Presenter\Presenter;
|
||||
// vendor
|
||||
class VendorPresenter extends Presenter {
|
||||
class VendorPresenter extends EntityPresenter {
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->entity->country ? $this->entity->country->name : '';
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
return link_to('/vendors/' . $this->entity->public_id, $this->entity->name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user