2018-11-02 11:54:46 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
|
|
|
|
namespace App\Models\Presenters;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* Class CompanyPresenter
|
|
|
|
* @package App\Models\Presenters
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
class CompanyPresenter extends EntityPresenter
|
|
|
|
{
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
public function name()
|
|
|
|
{
|
2019-01-25 11:47:23 +01:00
|
|
|
return $this->entity->name ?: ctrans('texts.untitled_account');
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|
|
|
|
|
2019-09-04 03:45:53 +02:00
|
|
|
public function logo()
|
|
|
|
{
|
2019-10-05 03:48:00 +02:00
|
|
|
return strlen($this->entity->getLogo() > 0) ? $this->entity->getLogo() : 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
2019-09-04 03:45:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-21 06:29:07 +02:00
|
|
|
public function address()
|
|
|
|
{
|
2019-08-21 23:46:11 +02:00
|
|
|
$str = '';
|
|
|
|
$company = $this->entity;
|
|
|
|
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($address1 = $company->settings->address1) {
|
2019-08-21 23:46:11 +02:00
|
|
|
$str .= e($address1) . '<br/>';
|
|
|
|
}
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($address2 = $company->settings->address2) {
|
2019-08-21 23:46:11 +02:00
|
|
|
$str .= e($address2) . '<br/>';
|
|
|
|
}
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($cityState = $this->getCompanyCityState()) {
|
2019-08-21 23:46:11 +02:00
|
|
|
$str .= e($cityState) . '<br/>';
|
|
|
|
}
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($country = $company->country()) {
|
2019-08-21 23:46:11 +02:00
|
|
|
$str .= e($country->name) . '<br/>';
|
|
|
|
}
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($company->settings->phone) {
|
|
|
|
$str .= ctrans('texts.work_phone') . ": ". e($company->settings->phone) .'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
2019-10-04 14:37:40 +02:00
|
|
|
if ($company->settings->email) {
|
|
|
|
$str .= ctrans('texts.work_email') . ": ". e($company->settings->email) .'<br/>';
|
2019-08-21 23:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
2019-08-21 06:29:07 +02:00
|
|
|
}
|
|
|
|
|
2019-10-04 14:37:40 +02:00
|
|
|
public function getCompanyCityState()
|
|
|
|
{
|
|
|
|
$company = $this->entity;
|
|
|
|
|
|
|
|
$swap = $company->country() && $company->country()->swap_postal_code;
|
|
|
|
|
|
|
|
$city = e($company->settings->city);
|
|
|
|
$state = e($company->settings->state);
|
|
|
|
$postalCode = e($company->settings->postal_code);
|
|
|
|
|
|
|
|
if ($city || $state || $postalCode) {
|
|
|
|
return $this->cityStateZip($city, $state, $postalCode, $swap);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|