2018-10-22 14:04:37 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2018-10-22 14:04:37 +02:00
|
|
|
|
|
|
|
namespace App\Models\Presenters;
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-22 14:04:37 +02:00
|
|
|
use Laracasts\Presenter\Presenter;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class EntityPresenter.
|
2019-01-27 00:22:57 +01:00
|
|
|
*/
|
2018-10-22 14:04:37 +02:00
|
|
|
class EntityPresenter extends Presenter
|
|
|
|
{
|
2018-11-02 11:54:46 +01:00
|
|
|
use MakesHash;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
public function id()
|
|
|
|
{
|
|
|
|
return $this->encodePrimaryKey($this->entity->id);
|
|
|
|
}
|
2018-10-22 14:04:37 +02:00
|
|
|
|
|
|
|
public function url()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function path()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editUrl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @param bool $label
|
|
|
|
*/
|
2018-10-22 14:04:37 +02:00
|
|
|
public function statusLabel($label = false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function statusColor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function link()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function titledName()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @param bool $subColors
|
|
|
|
*/
|
2018-10-22 14:04:37 +02:00
|
|
|
public function calendarEvent($subColors = false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-21 23:46:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-21 13:27:02 +01:00
|
|
|
public function getShippingCityState($printCity = true, $printState = true, $printPostalCode = true)
|
2019-08-29 06:07:04 +02:00
|
|
|
{
|
|
|
|
$client = $this->entity;
|
|
|
|
$swap = $client->shipping_country && $client->shipping_country->swap_postal_code;
|
|
|
|
|
2023-01-21 13:27:02 +01:00
|
|
|
$city = ($printCity) ? e($client->shipping_city) : null;
|
|
|
|
$state = ($printState) ? e($client->shipping_state) : null;
|
|
|
|
$postalCode = ($printPostalCode) ? e($client->shipping_postal_code) : null;
|
2019-08-29 06:07:04 +02:00
|
|
|
|
|
|
|
if ($city || $state || $postalCode) {
|
|
|
|
return $this->cityStateZip($city, $state, $postalCode, $swap);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-21 23:46:11 +02:00
|
|
|
public function cityStateZip($city, $state, $postalCode, $swap)
|
|
|
|
{
|
|
|
|
$str = $city;
|
|
|
|
|
|
|
|
if ($state) {
|
|
|
|
if ($str) {
|
|
|
|
$str .= ', ';
|
|
|
|
}
|
|
|
|
$str .= $state;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($swap) {
|
2020-09-06 11:38:10 +02:00
|
|
|
return $postalCode.' '.$str;
|
2019-08-21 23:46:11 +02:00
|
|
|
} else {
|
2020-09-06 11:38:10 +02:00
|
|
|
return $str.' '.$postalCode;
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-04 00:51:50 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|