mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Mapped transformers
This commit is contained in:
parent
d49f2fe9c9
commit
81fc77d142
@ -22,6 +22,11 @@ class Contact extends EntityModel
|
||||
public static $fieldEmail = 'Contact - Email';
|
||||
public static $fieldPhone = 'Contact - Phone';
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Client');
|
||||
|
@ -16,4 +16,10 @@ class InvoiceItem extends EntityModel
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product');
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,31 @@ class AccountTransformer extends TransformerAbstract
|
||||
return [
|
||||
'account_key' => $account->account_key,
|
||||
'name' => $account->present()->name,
|
||||
'currency_id' => (int) $account->currency_id,
|
||||
'timezone_id' => (int) $account->timezone_id,
|
||||
'date_format_id' => (int) $account->date_format_id,
|
||||
'datetime_format_id' => (int) $account->datetime_format_id,
|
||||
'updated_at' => $account->updated_at,
|
||||
'deleted_at' => $account->deleted_at,
|
||||
'address1' => $account->address1,
|
||||
'address2' => $account->address2,
|
||||
'city' => $account->city,
|
||||
'state' => $account->state,
|
||||
'postal_code' => $account->postal_code,
|
||||
'country_id' => (int) $account->country_id,
|
||||
'invoice_terms' => $account->invoice_terms,
|
||||
'email_footer' => $account->email_footer,
|
||||
'industry_id' => (int) $account->industry_id,
|
||||
'size_id' => (int) $account->size_id,
|
||||
'invoice_taxes' => (bool) $account->invoice_taxes,
|
||||
'invoice_item_taxes' => (bool) $account->invoice_item_taxes,
|
||||
'invoice_design_id' => (int) $account->invoice_design_id,
|
||||
'work_phone' => $account->work_phone,
|
||||
'work_email' => $account->work_email,
|
||||
'language_id' => (int) $account->language_id,
|
||||
'fill_products' => (bool) $account->fill_products,
|
||||
'update_products' => (bool) $account->update_products,
|
||||
'vat_number' => $account->vat_number
|
||||
];
|
||||
}
|
||||
}
|
@ -39,10 +39,33 @@ class ClientTransformer extends TransformerAbstract
|
||||
public function transform(Client $client)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $client->public_id,
|
||||
'public_id' => (int) $client->public_id,
|
||||
'name' => $client->name,
|
||||
'balance' => (float) $client->balance,
|
||||
'paid_to_date' => (float) $client->paid_to_date,
|
||||
'user_id' => (int) $client->user_id,
|
||||
'account_key' => $client->account->account_key,
|
||||
'updated_at' => $client->updated_at,
|
||||
'deleted_at' => $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,
|
||||
'work_phone' => $client->work_phone,
|
||||
'private_notes' => $client->private_notes,
|
||||
'balance' => (float) $client->balance,
|
||||
'paid_to_date' => $client->paid_to_date,
|
||||
'last_login' => $client->last_login,
|
||||
'website' => $client->website,
|
||||
'industry_id' => (int) $client->industry_id,
|
||||
'size_id' => (int) $client->size_id,
|
||||
'is_deleted' => (bool) $client->is_deleted,
|
||||
'payment_terms' => (int) $client->payment_terms,
|
||||
'vat_number' => $client->vat_number,
|
||||
'id_number' => $client->id_number,
|
||||
'language_id' => (int) $client->language_id
|
||||
];
|
||||
}
|
||||
}
|
@ -9,10 +9,17 @@ class ContactTransformer extends TransformerAbstract
|
||||
public function transform(Contact $contact)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $contact->public_id,
|
||||
'public_id' => (int) $contact->public_id,
|
||||
'first_name' => $contact->first_name,
|
||||
'last_name' => $contact->last_name,
|
||||
'email' => $contact->email,
|
||||
'user_id' => (int) $contact->user_id,
|
||||
'updated_at' => $contact->updated_at,
|
||||
'deleted_at' => $contact->deleted_at,
|
||||
'is_primary' => (bool) $contact->is_primary,
|
||||
'phone' => $contact->phone,
|
||||
'last_login' => $contact->last_login,
|
||||
'account_key' => $contact->account->account_key
|
||||
];
|
||||
}
|
||||
}
|
@ -9,8 +9,20 @@ class InvoiceItemTransformer extends TransformerAbstract
|
||||
public function transform(InvoiceItem $item)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $item->public_id,
|
||||
'public_id' => (int) $item->public_id,
|
||||
'product_key' => $item->product_key,
|
||||
'account_key' => $item->account->account_key,
|
||||
'user_id' => (int) $item->user_id,
|
||||
'invoice_id' => (int) $item->invoice_id,
|
||||
'product_id' => (int) $item->product_id,
|
||||
'updated_at' => $item->updated_at,
|
||||
'deleted_at' => $item->deleted_at,
|
||||
'product_key' => $item->product_key,
|
||||
'notes' => $item->notes,
|
||||
'cost' => (float) $item->cost,
|
||||
'qty' => (float) $item->qty,
|
||||
'tax_name' => $item->tax_name,
|
||||
'tax_rate' => $item->tax_rate
|
||||
];
|
||||
}
|
||||
}
|
@ -18,10 +18,37 @@ class InvoiceTransformer extends TransformerAbstract
|
||||
public function transform(Invoice $invoice)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $invoice->public_id,
|
||||
'public_id' => (int) $invoice->public_id,
|
||||
'invoice_number' => $invoice->invoice_number,
|
||||
'amount' => (float) $invoice->amount,
|
||||
'balance' => (float) $invoice->balance,
|
||||
'client_id' => (int) $invoice->client_id,
|
||||
'invoice_status_id' => (int) $invoice->invoice_status_id,
|
||||
'updated_at' => $invoice->updated_at,
|
||||
'deleted_at' => $invoice->deleted_at,
|
||||
'invoice_number' => $invoice->invoice_number,
|
||||
'discount' => (double) $invoice->discount,
|
||||
'po_number' => $invoice->po_number,
|
||||
'invoice_date' => $invoice->invoice_date,
|
||||
'due_date' => $invoice->due_date,
|
||||
'terms' => $invoice->terms,
|
||||
'public_notes' => $invoice->public_notes,
|
||||
'is_deleted' => (bool) $invoice->is_deleted,
|
||||
'is_recurring' => (bool) $invoice->is_recurring,
|
||||
'frequency_id' => (int) $invoice->frequency_id,
|
||||
'start_date' => $invoice->start_date,
|
||||
'end_date' => $invoice->end_date,
|
||||
'last_sent_date' => $invoice->last_sent_date,
|
||||
'recurring_invoice_id' => (int) $invoice->recurring_invoice_id,
|
||||
'tax_name' => $invoice->tax_name,
|
||||
'tax_rate' => (float) $invoice->tax_rate,
|
||||
'amount' => (float) $invoice->amount,
|
||||
'balance' => (float) $invoice->balance,
|
||||
'is_amount_discount' => (bool) $invoice->is_amount_discount,
|
||||
'invoice_footer' => $invoice->invoice_footer,
|
||||
'partial' => (float) $invoice->partial,
|
||||
'has_tasks' => (bool) $invoice->has_tasks,
|
||||
'auto_bill' => (bool) $invoice->auto_bill
|
||||
];
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ class QuoteTransformer extends TransformerAbstract
|
||||
public function transform(Invoice $invoice)
|
||||
{
|
||||
return [
|
||||
'id' => (int) $invoice->public_id,
|
||||
'public_id' => (int) $invoice->public_id,
|
||||
'quote_number' => $invoice->invoice_number,
|
||||
'amount' => (float) $invoice->amount,
|
||||
];
|
||||
|
@ -9,10 +9,19 @@ class UserTransformer extends TransformerAbstract
|
||||
public function transform(User $user)
|
||||
{
|
||||
return [
|
||||
'id' => (int) ($user->public_id + 1),
|
||||
'public_id' => (int) ($user->public_id + 1),
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
'email' => $user->email,
|
||||
'account_key' => $user->account->account_key,
|
||||
'updated_at' => $user->updated_at,
|
||||
'deleted_at' => $user->deleted_at,
|
||||
'phone' => $user->phone,
|
||||
'username' => $user->username,
|
||||
'registered' => (bool) $user->registered,
|
||||
'confirmed' => (bool) $user->confirmed,
|
||||
'oauth_user_id' => $user->oauth_user_id,
|
||||
'oauth_provider_id' => $user->oauth_provider_id
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user