mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
ba75a44eb8
* Adopt Laravel coding style The Laravel framework adopts the PSR-2 coding style with some additions. Laravel apps *should* adopt this coding style as well. However, Shift allows you to customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config to your project. You may use [Shift's .php_cs][2] file as a base. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 * Shift bindings PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser. * Shift core files * Shift to Throwable * Add laravel/ui dependency * Unindent vendor mail templates * Shift config files * Default config files In an effort to make upgrading the constantly changing config files easier, Shift defaulted them so you can review the commit diff for changes. Moving forward, you should use ENV variables or create a separate config file to allow the core config files to remain automatically upgradeable. * Shift Laravel dependencies * Shift cleanup * Upgrade to Laravel 7 Co-authored-by: Laravel Shift <shift@laravelshift.com>
159 lines
3.0 KiB
PHP
159 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://opensource.org/licenses/AAL
|
|
*/
|
|
|
|
namespace App\Models\Presenters;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
use Hashids\Hashids;
|
|
use Laracasts\Presenter\Presenter;
|
|
use stdClass;
|
|
use URL;
|
|
use Utils;
|
|
|
|
/**
|
|
* Class EntityPresenter.
|
|
*/
|
|
class EntityPresenter extends Presenter
|
|
{
|
|
use MakesHash;
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function id()
|
|
{
|
|
return $this->encodePrimaryKey($this->entity->id);
|
|
}
|
|
|
|
public function url()
|
|
{
|
|
}
|
|
|
|
public function path()
|
|
{
|
|
}
|
|
|
|
public function editUrl()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @param bool $label
|
|
*/
|
|
public function statusLabel($label = false)
|
|
{
|
|
}
|
|
|
|
public function statusColor()
|
|
{
|
|
}
|
|
|
|
public function link()
|
|
{
|
|
}
|
|
|
|
public function titledName()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @param bool $subColors
|
|
*/
|
|
public function calendarEvent($subColors = false)
|
|
{
|
|
}
|
|
|
|
public function getCityState()
|
|
{
|
|
$client = $this->entity;
|
|
$swap = $client->country && $client->country->swap_postal_code;
|
|
|
|
$city = e($client->city);
|
|
$state = e($client->state);
|
|
$postalCode = e($client->postal_code);
|
|
|
|
if ($city || $state || $postalCode) {
|
|
return $this->cityStateZip($city, $state, $postalCode, $swap);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function getShippingCityState()
|
|
{
|
|
$client = $this->entity;
|
|
$swap = $client->shipping_country && $client->shipping_country->swap_postal_code;
|
|
|
|
$city = e($client->shipping_city);
|
|
$state = e($client->shipping_state);
|
|
$postalCode = e($client->shipping_postal_code);
|
|
|
|
if ($city || $state || $postalCode) {
|
|
return $this->cityStateZip($city, $state, $postalCode, $swap);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function cityStateZip($city, $state, $postalCode, $swap)
|
|
{
|
|
$str = $city;
|
|
|
|
if ($state) {
|
|
if ($str) {
|
|
$str .= ', ';
|
|
}
|
|
$str .= $state;
|
|
}
|
|
|
|
if ($swap) {
|
|
return $postalCode.' '.$str;
|
|
} else {
|
|
return $str.' '.$postalCode;
|
|
}
|
|
}
|
|
|
|
public function clientName()
|
|
{
|
|
return $this->client->present()->name();
|
|
}
|
|
|
|
public function address()
|
|
{
|
|
return $this->client->present()->address();
|
|
}
|
|
|
|
public function shippingAddress()
|
|
{
|
|
return $this->client->present()->shipping_address();
|
|
}
|
|
|
|
public function companyLogo()
|
|
{
|
|
return $this->company->logo;
|
|
}
|
|
|
|
public function clientLogo()
|
|
{
|
|
return $this->client->logo;
|
|
}
|
|
|
|
public function companyName()
|
|
{
|
|
return $this->company->present()->name();
|
|
}
|
|
|
|
public function companyAddress()
|
|
{
|
|
return $this->company->present()->address();
|
|
}
|
|
}
|