1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Models/Presenters/ClientPresenter.php
2019-09-16 14:59:59 +10:00

91 lines
2.3 KiB
PHP

<?php
/**
* 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
*/
namespace App\Models\Presenters;
/**
* Class ClientPresenter
* @package App\Models\Presenters
*/
class ClientPresenter extends EntityPresenter
{
/**
* @return string
*/
public function name()
{
return $this->entity->name ?: $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name;
}
public function primary_contact_name()
{
return $this->entity->primary_contact->first() !== null ? $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name : 'No primary contact set';
}
public function email()
{
return $this->entity->primary_contact->first() !== null ? $this->entity->primary_contact->first()->email : 'No Email Set';
}
public function address()
{
$str = '';
$client = $this->entity;
if ($address1 = $client->address1) {
$str .= e($address1) . '<br/>';
}
if ($address2 = $client->address2) {
$str .= e($address2) . '<br/>';
}
if ($cityState = $this->getCityState()) {
$str .= e($cityState) . '<br/>';
}
if ($country = $client->country) {
$str .= e($country->name) . '<br/>';
}
return $str;
}
public function shipping_address()
{
$str = '';
$client = $this->entity;
if ($address1 = $client->shipping_address1) {
$str .= e($address1) . '<br/>';
}
if ($address2 = $client->shipping_address2) {
$str .= e($address2) . '<br/>';
}
if ($cityState = $this->getCityState()) {
$str .= e($cityState) . '<br/>';
}
if ($country = $client->country) {
$str .= e($country->name) . '<br/>';
}
return $str;
}
public function phone()
{
return $this->entity->phone ?: '';
}
public function website()
{
return $this->entity->website ?: '';
}
}