v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@@ -17,8 +17,8 @@ class Permission extends TransformerAbstract
'id' => $model->id,
'name' => $model->display_name,
'code' => $model->name,
'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() : '',
];
}
}

View File

@@ -22,8 +22,8 @@ class Role extends TransformerAbstract
'id' => $model->id,
'name' => $model->display_name,
'code' => $model->name,
'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() : '',
];
}

View File

@@ -2,7 +2,7 @@
namespace App\Transformers\Auth;
use App\Transformers\Company\Company;
use App\Transformers\Common\Company;
use App\Models\Auth\User as Model;
use League\Fractal\TransformerAbstract;
@@ -23,8 +23,8 @@ class User extends TransformerAbstract
'id' => $model->id,
'name' => $model->name,
'email' => $model->email,
'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() : '',
];
}

View File

@@ -25,8 +25,8 @@ class Account extends TransformerAbstract
'bank_phone' => $model->bank_phone,
'bank_address' => $model->bank_address,
'enabled' => $model->enabled,
'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() : '',
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Transformers\Banking;
use App\Models\Banking\Reconciliation as Model;
use League\Fractal\TransformerAbstract;
class Reconciliation extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['account'];
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'account_id' => $model->account_id,
'started_at' => $model->started_at->toIso8601String(),
'ended_at' => $model->ended_at->toIso8601String(),
'closing_balance' => $model->closing_balance,
'reconciled' => $model->reconciled,
'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());
}
}

View File

@@ -1,20 +1,19 @@
<?php
namespace App\Transformers\Expense;
namespace App\Transformers\Banking;
use App\Transformers\Banking\Account;
use App\Transformers\Expense\Vendor;
use App\Transformers\Common\Contact;
use App\Transformers\Setting\Category;
use App\Transformers\Setting\Currency;
use App\Models\Expense\Payment as Model;
use App\Models\Banking\Transaction as Model;
use League\Fractal\TransformerAbstract;
class Payment extends TransformerAbstract
class Transaction extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['account', 'category', 'currency', 'vendor'];
protected $defaultIncludes = ['account', 'category', 'contact', 'currency'];
/**
* @param Model $model
@@ -25,12 +24,14 @@ class Payment extends TransformerAbstract
return [
'id' => $model->id,
'company_id' => $model->company_id,
'type' => $model->type,
'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,
'document_id' => $model->document_id,
'contact_id' => $model->contact_id,
'description' => $model->description,
'category_id' => $model->category_id,
'payment_method' => $model->payment_method,
@@ -72,12 +73,12 @@ class Payment extends TransformerAbstract
* @param Model $model
* @return mixed
*/
public function includeVendor(Model $model)
public function includeContact(Model $model)
{
if (!$model->vendor) {
if (!$model->contact) {
return $this->null();
}
return $this->item($model->vendor, new Vendor());
return $this->item($model->contact, new Contact());
}
}

View File

@@ -2,8 +2,6 @@
namespace App\Transformers\Banking;
use App\Transformers\Expense\Payment;
use App\Transformers\Income\Revenue;
use App\Models\Banking\Transfer as Model;
use League\Fractal\TransformerAbstract;
@@ -12,7 +10,7 @@ class Transfer extends TransformerAbstract
/**
* @var array
*/
protected $defaultIncludes = ['payment', 'revenue'];
protected $defaultIncludes = [];
/**
* @param Model $model
@@ -20,31 +18,21 @@ class Transfer extends TransformerAbstract
*/
public function transform(Model $model)
{
$expense_transaction = $model->expense_transaction;
$income_transaction = $model->income_transaction;
return [
'id' => $model->id,
'company_id' => $model->company_id,
'payment_id' => $model->payment_id,
'revenue_id' => $model->revenue_id,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'from_account' => $expense_transaction->account->name,
'from_account_id' => $expense_transaction->account->id,
'to_account' => $income_transaction->account->name,
'to_account_id' => $income_transaction->account->id,
'amount' => $expense_transaction->amount,
'currency_code' => $expense_transaction->currency_code,
'paid_at' => $expense_transaction->paid_at ? $expense_transaction->paid_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 includePayment(Model $model)
{
return $this->item($model->payment, new Payment());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeRevenue(Model $model)
{
return $this->item($model->revenue, new Revenue());
}
}

View File

@@ -15,19 +15,14 @@ class Company extends TransformerAbstract
{
return [
'id' => $model->id,
'name' => $model->company_name,
'email' => $model->company_email,
'name' => $model->name,
'email' => $model->email,
'domain' => $model->domain,
'address' => $model->company_address,
'logo' => $model->company_logo,
'default_account' => $model->default_account,
'default_currency' => $model->default_currency,
'default_tax' => $model->default_tax,
'default_payment_method' => $model->default_payment_method,
'default_language' => $model->default_language,
'address' => $model->address,
'logo' => $model->logo,
'enabled' => $model->enabled,
'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() : '',
];
}
}

View File

@@ -1,11 +1,11 @@
<?php
namespace App\Transformers\Income;
namespace App\Transformers\Common;
use App\Models\Income\Customer as Model;
use App\Models\Common\Contact as Model;
use League\Fractal\TransformerAbstract;
class Customer extends TransformerAbstract
class Contact extends TransformerAbstract
{
/**
* @param Model $model
@@ -17,6 +17,7 @@ class Customer extends TransformerAbstract
'id' => $model->id,
'company_id' => $model->company_id,
'user_id' => $model->user_id,
'type' => $model->type,
'name' => $model->name,
'email' => $model->email,
'tax_number' => $model->tax_number,
@@ -25,8 +26,9 @@ class Customer extends TransformerAbstract
'website' => $model->website,
'currency_code' => $model->currency_code,
'enabled' => $model->enabled,
'created_at' => $model->created_at->toIso8601String(),
'updated_at' => $model->updated_at->toIso8601String(),
'reference' => $model->reference,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@@ -24,17 +24,15 @@ class Item extends TransformerAbstract
'id' => $model->id,
'company_id' => $model->company_id,
'name' => $model->name,
'sku' => $model->sku,
'description' => $model->description,
'sale_price' => $model->sale_price,
'purchase_price' => $model->purchase_price,
'quantity' => $model->quantity,
'category_id' => $model->category_id,
'tax_id' => $model->tax_id,
'picture' => $model->picture,
'enabled' => $model->enabled,
'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() : '',
];
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Transformers\Common;
use App\Models\Common\Report as Model;
use League\Fractal\TransformerAbstract;
class Report extends TransformerAbstract
{
/**
* @param Model $model
* @return array
*/
public function transform(Model $model)
{
return [
'id' => $model->id,
'company_id' => $model->company_id,
'name' => $model->name,
'alias' => $model->alias,
'description' => $model->description,
'type' => $model->type,
'group' => $model->group,
'period' => $model->period,
'basis' => $model->basis,
'graph' => $model->graph,
'enabled' => $model->enabled,
'created_at' => $model->created_at ? $model->created_at->toIso8601String() : '',
'updated_at' => $model->updated_at ? $model->updated_at->toIso8601String() : '',
];
}
}

View File

@@ -1,8 +0,0 @@
<?php
namespace App\Transformers\Company;
/**
* @deprecated since 1.2.7 version. use Common\Company instead.
*/
class Company extends \App\Transformers\Common\Company {}

View File

@@ -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());
}
}

View File

@@ -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() : '',
];
}
}

View File

@@ -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() : '',
];
}
}

View File

@@ -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());
}
}

View File

@@ -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() : '',
];
}
}

View File

@@ -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() : '',
];
}
}

View File

@@ -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(),
];
}
}

View File

@@ -2,11 +2,8 @@
namespace App\Transformers\Income;
use App\Transformers\Income\Customer;
use App\Transformers\Income\InvoiceHistories;
use App\Transformers\Income\InvoiceItems;
use App\Transformers\Income\InvoicePayments;
use App\Transformers\Income\InvoiceStatus;
use App\Transformers\Banking\Transaction;
use App\Transformers\Common\Contact;
use App\Transformers\Setting\Currency;
use App\Models\Income\Invoice as Model;
use League\Fractal\TransformerAbstract;
@@ -16,7 +13,7 @@ class Invoice extends TransformerAbstract
/**
* @var array
*/
protected $defaultIncludes = ['currency', 'customer', 'histories', 'items', 'payments', 'status'];
protected $defaultIncludes = ['contact', 'currency', 'histories', 'items', 'status', 'transactions'];
/**
* @param Model $model
@@ -30,24 +27,33 @@ class Invoice extends TransformerAbstract
'invoice_number' => $model->invoice_number,
'order_number' => $model->order_number,
'invoice_status_code' => $model->invoice_status_code,
'invoiced_at' => $model->invoiced_at->toIso8601String(),
'due_at' => $model->due_at->toIso8601String(),
'invoiced_at' => $model->invoiced_at ? $model->invoiced_at->toIso8601String() : '',
'due_at' => $model->due_at ? $model->due_at->toIso8601String() : '',
'amount' => $model->amount,
'currency_code' => $model->currency_code,
'currency_rate' => $model->currency_rate,
'customer_id' => $model->customer_id,
'customer_name' => $model->customer_name,
'customer_email' => $model->customer_email,
'customer_tax_number' => $model->customer_tax_number,
'customer_phone' => $model->customer_phone,
'customer_address' => $model->customer_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
@@ -57,15 +63,6 @@ class Invoice extends TransformerAbstract
return $this->item($model->currency, new Currency());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
*/
public function includeCustomer(Model $model)
{
return $this->item($model->customer, new Customer());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
@@ -84,15 +81,6 @@ class Invoice extends TransformerAbstract
return $this->collection($model->items, new InvoiceItems());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includePayments(Model $model)
{
return $this->collection($model->payments, new InvoicePayments());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Item
@@ -101,4 +89,13 @@ class Invoice extends TransformerAbstract
{
return $this->item($model->status, new InvoiceStatus());
}
/**
* @param Model $model
* @return \League\Fractal\Resource\Collection
*/
public function includeTransactions(Model $model)
{
return $this->collection($model->transactions, new Transaction());
}
}

View File

@@ -20,8 +20,8 @@ class InvoiceHistories 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() : '',
];
}
}

View File

@@ -19,14 +19,12 @@ class InvoiceItems extends TransformerAbstract
'invoice_id' => $model->invoice_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() : '',
];
}
}

View File

@@ -1,58 +0,0 @@
<?php
namespace App\Transformers\Income;
use App\Transformers\Banking\Account;
use App\Transformers\Setting\Currency;
use App\Models\Income\InvoicePayment as Model;
use League\Fractal\TransformerAbstract;
class InvoicePayments 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,
'invoice_id' => $model->invoice_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());
}
}

View File

@@ -18,8 +18,8 @@ class InvoiceStatus 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() : '',
];
}
}

View File

@@ -22,8 +22,8 @@ class InvoiceTotals 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() : '',
];
}
}

View File

@@ -1,83 +0,0 @@
<?php
namespace App\Transformers\Income;
use App\Transformers\Banking\Account;
use App\Transformers\Income\Customer;
use App\Transformers\Setting\Category;
use App\Transformers\Setting\Currency;
use App\Models\Income\Revenue as Model;
use League\Fractal\TransformerAbstract;
class Revenue extends TransformerAbstract
{
/**
* @var array
*/
protected $defaultIncludes = ['account', 'category', 'currency', 'customer'];
/**
* @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,
'customer_id' => $model->customer_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 includeCustomer(Model $model)
{
if (!$model->customer) {
return $this->null();
}
return $this->item($model->customer, new Customer());
}
}

View File

@@ -1,8 +0,0 @@
<?php
namespace App\Transformers\Item;
/**
* @deprecated since 1.2.7 version. use Common\Item instead.
*/
class Item extends \App\Transformers\Common\Item {}

View File

@@ -20,8 +20,8 @@ class Category extends TransformerAbstract
'type' => $model->type,
'color' => $model->color,
'enabled' => $model->enabled,
'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() : '',
];
}
}

View File

@@ -25,8 +25,8 @@ class Currency extends TransformerAbstract
'symbol_first' => $model->symbol_first,
'decimal_mark' => $model->decimal_mark,
'thousands_separator' => $model->thousands_separator,
'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() : '',
];
}
}

View File

@@ -19,8 +19,8 @@ class Tax extends TransformerAbstract
'name' => $model->name,
'rate' => $model->rate,
'enabled' => $model->enabled,
'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() : '',
];
}
}