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 ClientPresenter
|
|
|
|
* @package App\Models\Presenters
|
|
|
|
*/
|
2018-11-02 11:54:46 +01:00
|
|
|
class ClientPresenter extends EntityPresenter
|
|
|
|
{
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-07 06:22:36 +01:00
|
|
|
public function name()
|
|
|
|
{
|
|
|
|
return $this->entity->name ?: $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name;
|
|
|
|
}
|
2019-08-21 06:29:07 +02:00
|
|
|
|
2019-09-02 07:08:26 +02:00
|
|
|
public function primary_contact_name()
|
|
|
|
{
|
|
|
|
return $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name;;
|
|
|
|
}
|
|
|
|
|
2019-08-21 06:29:07 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-29 06:58:04 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-21 06:29:07 +02:00
|
|
|
|
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
}
|