v2 first commit
This commit is contained in:
@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Transformers\Expense;
|
||||
|
||||
use App\Transformers\Expense\BillHistories;
|
||||
use App\Transformers\Expense\BillItems;
|
||||
use App\Transformers\Expense\BillPayments;
|
||||
use App\Transformers\Expense\BillStatus;
|
||||
use App\Transformers\Expense\Vendor;
|
||||
use App\Transformers\Banking\Transaction;
|
||||
use App\Transformers\Common\Contact;
|
||||
use App\Transformers\Setting\Currency;
|
||||
use App\Models\Expense\Bill as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
@ -16,7 +13,7 @@ class Bill extends TransformerAbstract
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['currency', 'histories', 'items', 'payments', 'status', 'vendor'];
|
||||
protected $defaultIncludes = ['contact', 'currency', 'histories', 'items', 'status', 'transactions'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
@ -30,24 +27,33 @@ class Bill extends TransformerAbstract
|
||||
'bill_number' => $model->bill_number,
|
||||
'order_number' => $model->order_number,
|
||||
'bill_status_code' => $model->invoice_status_code,
|
||||
'billed_at' => $model->billed_at->toIso8601String(),
|
||||
'due_at' => $model->due_at->toIso8601String(),
|
||||
'billed_at' => $model->billed_at ? $model->billed_at->toIso8601String() : '',
|
||||
'due_at' => $model->due_at ? $model->due_at->toIso8601String() : '',
|
||||
'amount' => $model->amount,
|
||||
'currency_code' => $model->currency_code,
|
||||
'currency_rate' => $model->currency_rate,
|
||||
'vendor_id' => $model->vendor_id,
|
||||
'vendor_name' => $model->vendor_name,
|
||||
'vendor_email' => $model->vendor_email,
|
||||
'vendor_tax_number' => $model->vendor_tax_number,
|
||||
'vendor_phone' => $model->vendor_phone,
|
||||
'vendor_address' => $model->vendor_address,
|
||||
'contact_id' => $model->contact_id,
|
||||
'contact_name' => $model->contact_name,
|
||||
'contact_email' => $model->contact_email,
|
||||
'contact_tax_number' => $model->contact_tax_number,
|
||||
'contact_phone' => $model->contact_phone,
|
||||
'contact_address' => $model->contact_address,
|
||||
'notes' => $model->notes,
|
||||
'attachment' => $model->attachment,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeContact(Model $model)
|
||||
{
|
||||
return $this->item($model->contact, new Contact());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
@ -75,15 +81,6 @@ class Bill extends TransformerAbstract
|
||||
return $this->collection($model->items, new BillItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includePayments(Model $model)
|
||||
{
|
||||
return $this->collection($model->payments, new BillPayments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
@ -95,10 +92,10 @@ class Bill extends TransformerAbstract
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeVendor(Model $model)
|
||||
public function includeTransactions(Model $model)
|
||||
{
|
||||
return $this->item($model->vendor, new Vendor());
|
||||
return $this->collection($model->transactions, new Transaction());
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ class BillHistories extends TransformerAbstract
|
||||
'status_code' => $model->status_code,
|
||||
'notify' => $model->notify,
|
||||
'description' => $model->description,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,12 @@ class BillItems extends TransformerAbstract
|
||||
'bill_id' => $model->bill_id,
|
||||
'item_id' => $model->item_id,
|
||||
'name' => $model->name,
|
||||
'sku' => $model->sku,
|
||||
'quantity' => $model->quantity,
|
||||
'price' => $model->price,
|
||||
'total' => $model->total,
|
||||
'tax' => $model->tax,
|
||||
'tax_id' => $model->tax_id,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Expense;
|
||||
|
||||
use App\Transformers\Banking\Account;
|
||||
use App\Transformers\Setting\Currency;
|
||||
use App\Models\Expense\BillPayment as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillPayments extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account', 'currency'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'bill_id' => $model->bill_id,
|
||||
'account_id' => $model->account_id,
|
||||
'paid_at' => $model->paid_at->toIso8601String(),
|
||||
'amount' => $model->amount,
|
||||
'currency_code' => $model->currency_code,
|
||||
'currency_rate' => $model->currency_rate,
|
||||
'description' => $model->description,
|
||||
'payment_method' => $model->payment_method,
|
||||
'reference' => $model->reference,
|
||||
'attachment' => $model->attachment,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeAccount(Model $model)
|
||||
{
|
||||
return $this->item($model->account, new Account());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCurrency(Model $model)
|
||||
{
|
||||
return $this->item($model->currency, new Currency());
|
||||
}
|
||||
}
|
@ -18,8 +18,8 @@ class BillStatus extends TransformerAbstract
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'code' => $model->code,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ class BillTotals extends TransformerAbstract
|
||||
'name' => $model->name,
|
||||
'amount' => $model->amount,
|
||||
'sort_order' => $model->sort_order,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
|
||||
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Expense;
|
||||
|
||||
use App\Transformers\Banking\Account;
|
||||
use App\Transformers\Expense\Vendor;
|
||||
use App\Transformers\Setting\Category;
|
||||
use App\Transformers\Setting\Currency;
|
||||
use App\Models\Expense\Payment as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Payment extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account', 'category', 'currency', 'vendor'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'account_id' => $model->account_id,
|
||||
'paid_at' => $model->paid_at->toIso8601String(),
|
||||
'amount' => $model->amount,
|
||||
'currency_code' => $model->currency_code,
|
||||
'currency_rate' => $model->currency_rate,
|
||||
'vendor_id' => $model->vendor_id,
|
||||
'description' => $model->description,
|
||||
'category_id' => $model->category_id,
|
||||
'payment_method' => $model->payment_method,
|
||||
'reference' => $model->reference,
|
||||
'attachment' => $model->attachment,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeAccount(Model $model)
|
||||
{
|
||||
return $this->item($model->account, new Account());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCurrency(Model $model)
|
||||
{
|
||||
return $this->item($model->currency, new Currency());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function includeVendor(Model $model)
|
||||
{
|
||||
if (!$model->vendor) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->vendor, new Vendor());
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers\Expense;
|
||||
|
||||
use App\Models\Expense\Vendor as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Vendor extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'user_id' => $model->user_id,
|
||||
'name' => $model->name,
|
||||
'email' => $model->email,
|
||||
'tax_number' => $model->tax_number,
|
||||
'phone' => $model->phone,
|
||||
'address' => $model->address,
|
||||
'website' => $model->website,
|
||||
'currency_code' => $model->currency_code,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user