account, $this->serializer); return $this->includeCollection($client->contacts, $transformer, ENTITY_CONTACT); } /** * @param Client $client * * @return \League\Fractal\Resource\Collection */ public function includeInvoices(Client $client) { $transformer = new InvoiceTransformer($this->account, $this->serializer, $client); return $this->includeCollection($client->invoices, $transformer, ENTITY_INVOICE); } /** * @param Client $client * * @return \League\Fractal\Resource\Collection */ public function includeCredits(Client $client) { $transformer = new CreditTransformer($this->account, $this->serializer); return $this->includeCollection($client->credits, $transformer, ENTITY_CREDIT); } /** * @param Client $client * * @return \League\Fractal\Resource\Collection */ public function includeExpenses(Client $client) { $transformer = new ExpenseTransformer($this->account, $this->serializer); return $this->includeCollection($client->expenses, $transformer, ENTITY_EXPENSE); } /** * @param Client $client * * @return array */ public function transform(Client $client) { return array_merge($this->getDefaults($client), [ 'id' => (int) $client->public_id, 'name' => $client->name ?: '', 'display_name' => $client->getDisplayName() ?: '', 'balance' => (float) ($client->balance ?: 0.0), 'paid_to_date' => (float) ($client->paid_to_date ?: 0.0), 'updated_at' => $this->getTimestamp($client->updated_at), 'archived_at' => $this->getTimestamp($client->deleted_at), 'address1' => $client->address1 ?: '', 'address2' => $client->address2 ?: '', 'city' => $client->city ?: '', 'state' => $client->state ?: '', 'postal_code' => $client->postal_code ?: '', 'country_id' => (int) ($client->country_id ?: 0), 'work_phone' => $client->work_phone ?: '', 'private_notes' => $client->private_notes ?: '', 'public_notes' => $client->public_notes ?: '', 'last_login' => $client->last_login ?: '', 'website' => $client->website ?: '', 'industry_id' => (int) ($client->industry_id ?: 0), 'size_id' => (int) ($client->size_id ?: 0), 'is_deleted' => (bool) $client->is_deleted, 'payment_terms' => (int) ($client->payment_terms ?: 0), 'vat_number' => $client->vat_number ?: '', 'id_number' => $client->id_number ?: '', 'language_id' => (int) ($client->language_id ?: 0), 'currency_id' => (int) ($client->currency_id ?: 0), 'custom_value1' => $client->custom_value1 ?: '', 'custom_value2' => $client->custom_value2 ?: '', 'invoice_number_counter' => (int) ($client->invoice_number_counter ?: 0), 'quote_number_counter' => (int) ($client->quote_number_counter ?: 0), 'task_rate' => (float) $client->task_rate, 'shipping_address1' => $client->shipping_address1 ?: '', 'shipping_address2' => $client->shipping_address2 ?: '', 'shipping_city' => $client->shipping_city ?: '', 'shipping_state' => $client->shipping_state ?: '', 'shipping_postal_code' => $client->shipping_postal_code ?: '', 'shipping_country_id' => (int) ($client->shipping_country_id ?: 0), 'show_tasks_in_portal' => (bool) $client->show_tasks_in_portal, 'send_reminders' => (bool) $client->send_reminders, 'credit_number_counter' => (int) ($client->credit_number_counter ?: 0), 'custom_messages' => json_encode($client->custom_messages), ]); } }