1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Models/Presenters/CompanyPresenter.php

94 lines
2.4 KiB
PHP
Raw Normal View History

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