mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Merge branch 'master' of github.com:hillelcoren/invoice-ninja
This commit is contained in:
commit
d68b78f926
@ -60,6 +60,11 @@ class Account extends Eloquent
|
|||||||
return $this->hasMany('App\Models\Client');
|
return $this->hasMany('App\Models\Client');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function contacts()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Contact');
|
||||||
|
}
|
||||||
|
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Invoice');
|
return $this->hasMany('App\Models\Invoice');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\AccountToken;
|
use App\Models\AccountToken;
|
||||||
|
use App\Models\Contact;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'users',
|
'users',
|
||||||
'clients',
|
'clients',
|
||||||
|
'invoices',
|
||||||
|
'contacts'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeUsers(Account $account)
|
public function includeUsers(Account $account)
|
||||||
@ -22,6 +25,16 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
return $this->collection($account->clients, new ClientTransformer($account));
|
return $this->collection($account->clients, new ClientTransformer($account));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeInvoices(Account $account)
|
||||||
|
{
|
||||||
|
return $this->collection($account->invoices, new InvoiceTransformer($account));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeContacts(Account $account)
|
||||||
|
{
|
||||||
|
return $this->collection($account->contacts, new ContactTransformer($account));
|
||||||
|
}
|
||||||
|
|
||||||
public function transform(Account $account)
|
public function transform(Account $account)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -41,9 +41,9 @@ class ClientTransformer extends EntityTransformer
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'contacts',
|
// 'contacts',
|
||||||
'invoices',
|
// 'invoices',
|
||||||
'quotes',
|
// 'quotes',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeContacts(Client $client)
|
public function includeContacts(Client $client)
|
||||||
@ -64,7 +64,7 @@ class ClientTransformer extends EntityTransformer
|
|||||||
public function transform(Client $client)
|
public function transform(Client $client)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'public_id' => (int) $client->public_id,
|
'id' => (int) $client->public_id,
|
||||||
'name' => $client->name,
|
'name' => $client->name,
|
||||||
'balance' => (float) $client->balance,
|
'balance' => (float) $client->balance,
|
||||||
'paid_to_date' => (float) $client->paid_to_date,
|
'paid_to_date' => (float) $client->paid_to_date,
|
||||||
|
@ -9,7 +9,7 @@ class ContactTransformer extends EntityTransformer
|
|||||||
public function transform(Contact $contact)
|
public function transform(Contact $contact)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'public_id' => (int) $contact->public_id,
|
'id' => (int) $contact->public_id,
|
||||||
'first_name' => $contact->first_name,
|
'first_name' => $contact->first_name,
|
||||||
'last_name' => $contact->last_name,
|
'last_name' => $contact->last_name,
|
||||||
'email' => $contact->email,
|
'email' => $contact->email,
|
||||||
@ -19,7 +19,8 @@ class ContactTransformer extends EntityTransformer
|
|||||||
'is_primary' => (bool) $contact->is_primary,
|
'is_primary' => (bool) $contact->is_primary,
|
||||||
'phone' => $contact->phone,
|
'phone' => $contact->phone,
|
||||||
'last_login' => $contact->last_login,
|
'last_login' => $contact->last_login,
|
||||||
'account_key' => $this->account->account_key
|
'account_key' => $this->account->account_key,
|
||||||
|
'client_id' => $contact->client_id
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ class InvoiceItemTransformer extends EntityTransformer
|
|||||||
public function transform(InvoiceItem $item)
|
public function transform(InvoiceItem $item)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'public_id' => (int) $item->public_id,
|
'id' => (int) $item->public_id,
|
||||||
'product_key' => $item->product_key,
|
'product_key' => $item->product_key,
|
||||||
'account_key' => $this->account->account_key,
|
'account_key' => $this->account->account_key,
|
||||||
'user_id' => (int) $item->user_id,
|
'user_id' => (int) $item->user_id,
|
||||||
|
@ -20,13 +20,11 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
* @SWG\Property(property="invoice_status_id", type="integer", example=1)
|
* @SWG\Property(property="invoice_status_id", type="integer", example=1)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected $client;
|
|
||||||
|
|
||||||
public function __construct(Account $account, Client $client)
|
public function __construct(Account $account)
|
||||||
{
|
{
|
||||||
parent::__construct($account);
|
parent::__construct($account);
|
||||||
|
|
||||||
$this->client = $client;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
@ -42,10 +40,9 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => (int) $invoice->public_id,
|
'id' => (int) $invoice->public_id,
|
||||||
'invoice_number' => $invoice->invoice_number,
|
|
||||||
'amount' => (float) $invoice->amount,
|
'amount' => (float) $invoice->amount,
|
||||||
'balance' => (float) $invoice->balance,
|
'balance' => (float) $invoice->balance,
|
||||||
'client_id' => (int) $this->client->public_id,
|
'client_id' => (int) $invoice->client->public_id,
|
||||||
'invoice_status_id' => (int) $invoice->invoice_status_id,
|
'invoice_status_id' => (int) $invoice->invoice_status_id,
|
||||||
'updated_at' => $invoice->updated_at,
|
'updated_at' => $invoice->updated_at,
|
||||||
'deleted_at' => $invoice->deleted_at,
|
'deleted_at' => $invoice->deleted_at,
|
||||||
@ -71,7 +68,8 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
'invoice_footer' => $invoice->invoice_footer,
|
'invoice_footer' => $invoice->invoice_footer,
|
||||||
'partial' => (float) $invoice->partial,
|
'partial' => (float) $invoice->partial,
|
||||||
'has_tasks' => (bool) $invoice->has_tasks,
|
'has_tasks' => (bool) $invoice->has_tasks,
|
||||||
'auto_bill' => (bool) $invoice->auto_bill
|
'auto_bill' => (bool) $invoice->auto_bill,
|
||||||
|
'account_key' => $this->account->account_key
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ class QuoteTransformer extends EntityTransformer
|
|||||||
public function transform(Invoice $invoice)
|
public function transform(Invoice $invoice)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'public_id' => (int) $invoice->public_id,
|
'id' => (int) $invoice->public_id,
|
||||||
'quote_number' => $invoice->invoice_number,
|
'quote_number' => $invoice->invoice_number,
|
||||||
'amount' => (float) $invoice->amount,
|
'amount' => (float) $invoice->amount,
|
||||||
];
|
];
|
||||||
|
@ -9,7 +9,7 @@ class UserTransformer extends EntityTransformer
|
|||||||
public function transform(User $user)
|
public function transform(User $user)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'public_id' => (int) ($user->public_id + 1),
|
'id' => (int) ($user->public_id + 1),
|
||||||
'first_name' => $user->first_name,
|
'first_name' => $user->first_name,
|
||||||
'last_name' => $user->last_name,
|
'last_name' => $user->last_name,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user