diff --git a/app/Models/Client.php b/app/Models/Client.php index c8baf45da66f..521527a2f125 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -320,7 +320,7 @@ class Client extends BaseModel //Also need to harvest the list of client gateway tokens and present these //for instant payment - $company_gateways = $this->client->getSetting('company_gateway_ids'); + $company_gateways = $this->getSetting('company_gateway_ids'); if($company_gateways) $gateways = $this->company->company_gateways->whereIn('id', $payment_gateways); diff --git a/app/Transformers/ClientGatewayTokenTransformer.php b/app/Transformers/ClientGatewayTokenTransformer.php new file mode 100644 index 000000000000..d947e1aee4f4 --- /dev/null +++ b/app/Transformers/ClientGatewayTokenTransformer.php @@ -0,0 +1,44 @@ + $this->encodePrimaryKey($cgt->id), + 'token' => (string)$cgt->token ?: '', + 'gateway_customer_reference' => $cgt->gateway_customer_reference ?: '', + 'gateway_type_id' => (string)$cgt->gateway_type_id ?: '', + 'company_gateway_id' => (string)$this->encodePrimaryKey($cgt->company_gateway_id) ?: '', + 'is_default' => (bool) $cgt->is_default, + 'updated_at' => $cgt->updated_at, + 'archived_at' => $cgt->deleted_at, + ]; + } +} diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index f80e2d81b0cf..53059ad40418 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -13,6 +13,8 @@ namespace App\Transformers; use App\Models\Client; use App\Models\ClientContact; +use App\Models\ClientGatewayToken; +use App\Transformers\ClientGatewayTokenTransformer; use App\Utils\Traits\MakesHash; /** @@ -30,6 +32,7 @@ class ClientTransformer extends EntityTransformer * @var array */ protected $availableIncludes = [ + 'gateway_tokens' ]; @@ -45,7 +48,12 @@ class ClientTransformer extends EntityTransformer return $this->includeCollection($client->contacts, $transformer, ClientContact::class); } + public function includeGatewayTokens(Client $client) + { + $transformer = new ClientGatewayTokenTransformer($this->serializer); + return $this->includeCollection($client->gateway_tokens, $transformer, ClientGatewayToken::class); + } /** * @param Client $client * @@ -65,6 +73,7 @@ class ClientTransformer extends EntityTransformer 'last_login' => (int)$client->last_login, 'address1' => $client->address1 ?: '', 'address2' => $client->address2 ?: '', + 'phone' => $client->phone ?: '', 'city' => $client->city ?: '', 'state' => $client->state ?: '', 'postal_code' => $client->postal_code ?: '', diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 0bce0cb6a1ad..da50c2f3b20a 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -70,13 +70,13 @@ class Number $swapSymbol = $currency->swap_currency_symbol; /* Country settings override client settings */ - if (property_exists($client->country, 'thousand_separator')) + if(isset($client->country->thousand_separator)) $thousand = $client->country->thousand_separator; - if (property_exists($client->country, 'decimal_separator')) + if(isset($client->country->decimal_separator)) $decimal = $client->country->decimal_separator; - if(property_exists($client->country, 'swap_currency_symbol')) + if(isset($client->country->swap_currency_symbol)) $swapSymbol = $client->country->swap_currency_symbol; $value = number_format($value, $precision, $decimal, $thousand); diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 931d6eb8ad4c..b32be6acea9b 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -274,6 +274,7 @@ class CreateUsersTable extends Migration $table->text('private_notes')->nullable(); $table->text('client_hash')->nullable(); $table->string('logo', 255)->nullable(); + $table->string('phone', 255)->nullable(); $table->decimal('balance', 13, 2)->default(0); $table->decimal('paid_to_date', 13, 2)->default(0);