first commit
This commit is contained in:
24
app/Http/Transformers/Auth/Permission.php
Normal file
24
app/Http/Transformers/Auth/Permission.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Auth;
|
||||
|
||||
use App\Models\Auth\Permission as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Permission extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'name' => $model->display_name,
|
||||
'code' => $model->name,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Transformers/Auth/Role.php
Normal file
38
app/Http/Transformers/Auth/Role.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Auth;
|
||||
|
||||
use App\Models\Auth\Role as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Role extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['permissions'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'name' => $model->display_name,
|
||||
'code' => $model->name,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includePermissions(Model $model)
|
||||
{
|
||||
return $this->collection($model->permissions, new Permission());
|
||||
}
|
||||
}
|
||||
38
app/Http/Transformers/Auth/User.php
Normal file
38
app/Http/Transformers/Auth/User.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Auth;
|
||||
|
||||
use App\Models\Auth\User as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class User extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['roles'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'name' => $model->name,
|
||||
'email' => $model->email,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeRoles(Model $model)
|
||||
{
|
||||
return $this->collection($model->roles, new Role());
|
||||
}
|
||||
}
|
||||
32
app/Http/Transformers/Banking/Account.php
Normal file
32
app/Http/Transformers/Banking/Account.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Banking;
|
||||
|
||||
use App\Models\Banking\Account as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Account extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'number' => $model->number,
|
||||
'currency_code' => $model->currency_code,
|
||||
'opening_balance' => $model->opening_balance,
|
||||
'current_balance' => $model->balance,
|
||||
'bank_name' => $model->bank_name,
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
app/Http/Transformers/Banking/Transfer.php
Normal file
50
app/Http/Transformers/Banking/Transfer.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Banking;
|
||||
|
||||
use App\Http\Transformers\Expense\Payment;
|
||||
use App\Http\Transformers\Income\Revenue;
|
||||
use App\Models\Banking\Transfer as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Transfer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['payment', 'revenue'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
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(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
24
app/Http/Transformers/Company/Company.php
Normal file
24
app/Http/Transformers/Company/Company.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Company;
|
||||
|
||||
use App\Models\Company\Company as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Company extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'domain' => $model->domain,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
94
app/Http/Transformers/Expense/Bill.php
Normal file
94
app/Http/Transformers/Expense/Bill.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Http\Transformers\Expense\BillHistories;
|
||||
use App\Http\Transformers\Expense\BillItems;
|
||||
use App\Http\Transformers\Expense\BillPayments;
|
||||
use App\Http\Transformers\Expense\BillStatus;
|
||||
use App\Http\Transformers\Expense\Vendor;
|
||||
use App\Models\Expense\Bill as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Bill extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['vendor', 'status', 'items', 'payments', 'histories'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'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(),
|
||||
'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,
|
||||
'notes' => $model->notes,
|
||||
'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 includeVendor(Model $model)
|
||||
{
|
||||
return $this->item($model->vendor, new Vendor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeStatus(Model $model)
|
||||
{
|
||||
return $this->item($model->status, new BillStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeItems(Model $model)
|
||||
{
|
||||
return $this->collection($model->items, new BillItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeHistories(Model $model)
|
||||
{
|
||||
return $this->collection($model->histories, new BillHistories());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includePayments(Model $model)
|
||||
{
|
||||
return $this->collection($model->payments, new BillPayments());
|
||||
}
|
||||
}
|
||||
27
app/Http/Transformers/Expense/BillHistories.php
Normal file
27
app/Http/Transformers/Expense/BillHistories.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Models\Expense\BillHistory as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillHistories extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'bill_id' => $model->bill_id,
|
||||
'status_code' => $model->status_code,
|
||||
'notify' => $model->notify,
|
||||
'description' => $model->description,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Transformers/Expense/BillItems.php
Normal file
32
app/Http/Transformers/Expense/BillItems.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Models\Expense\BillItem as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillItems extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
48
app/Http/Transformers/Expense/BillPayments.php
Normal file
48
app/Http/Transformers/Expense/BillPayments.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Http\Transformers\Banking\Account;
|
||||
use App\Models\Expense\BillPayment as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillPayments 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,
|
||||
'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());
|
||||
}
|
||||
}
|
||||
25
app/Http/Transformers/Expense/BillStatus.php
Normal file
25
app/Http/Transformers/Expense/BillStatus.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Models\Expense\BillStatus as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillStatus extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'code' => $model->code,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
app/Http/Transformers/Expense/Payment.php
Normal file
69
app/Http/Transformers/Expense/Payment.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Http\Transformers\Banking\Account;
|
||||
use App\Http\Transformers\Expense\Vendor;
|
||||
use App\Http\Transformers\Setting\Category;
|
||||
use App\Models\Expense\Payment as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Payment extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account', 'vendor', 'category'];
|
||||
|
||||
/**
|
||||
* @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 includeVendor(Model $model)
|
||||
{
|
||||
return $this->item($model->vendor, new Vendor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
}
|
||||
32
app/Http/Transformers/Expense/Vendor.php
Normal file
32
app/Http/Transformers/Expense/Vendor.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Transformers/Income/Customer.php
Normal file
32
app/Http/Transformers/Income/Customer.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Models\Income\Customer as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Customer 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
94
app/Http/Transformers/Income/Invoice.php
Normal file
94
app/Http/Transformers/Income/Invoice.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Http\Transformers\Income\Customer;
|
||||
use App\Http\Transformers\Income\InvoiceHistories;
|
||||
use App\Http\Transformers\Income\InvoiceItems;
|
||||
use App\Http\Transformers\Income\InvoicePayments;
|
||||
use App\Http\Transformers\Income\InvoiceStatus;
|
||||
use App\Models\Income\Invoice as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Invoice extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['customer', 'status', 'items', 'payments', 'histories'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'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(),
|
||||
'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,
|
||||
'notes' => $model->notes,
|
||||
'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 includeCustomer(Model $model)
|
||||
{
|
||||
return $this->item($model->customer, new Customer());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeStatus(Model $model)
|
||||
{
|
||||
return $this->item($model->status, new InvoiceStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeItems(Model $model)
|
||||
{
|
||||
return $this->collection($model->items, new InvoiceItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeHistories(Model $model)
|
||||
{
|
||||
return $this->collection($model->histories, new InvoiceHistories());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includePayments(Model $model)
|
||||
{
|
||||
return $this->collection($model->payments, new InvoicePayments());
|
||||
}
|
||||
}
|
||||
27
app/Http/Transformers/Income/InvoiceHistories.php
Normal file
27
app/Http/Transformers/Income/InvoiceHistories.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Models\Income\InvoiceHistory as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class InvoiceHistories extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'invoice_id' => $model->invoice_id,
|
||||
'status_code' => $model->status_code,
|
||||
'notify' => $model->notify,
|
||||
'description' => $model->description,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Transformers/Income/InvoiceItems.php
Normal file
32
app/Http/Transformers/Income/InvoiceItems.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Models\Income\InvoiceItem as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class InvoiceItems extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
48
app/Http/Transformers/Income/InvoicePayments.php
Normal file
48
app/Http/Transformers/Income/InvoicePayments.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Http\Transformers\Banking\Account;
|
||||
use App\Models\Income\InvoicePayment as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class InvoicePayments 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,
|
||||
'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());
|
||||
}
|
||||
}
|
||||
25
app/Http/Transformers/Income/InvoiceStatus.php
Normal file
25
app/Http/Transformers/Income/InvoiceStatus.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Models\Income\InvoiceStatus as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class InvoiceStatus extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'code' => $model->code,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
app/Http/Transformers/Income/Revenue.php
Normal file
69
app/Http/Transformers/Income/Revenue.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Http\Transformers\Banking\Account;
|
||||
use App\Http\Transformers\Income\Customer;
|
||||
use App\Http\Transformers\Setting\Category;
|
||||
use App\Models\Income\Revenue as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Revenue extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['account', 'customer', 'category'];
|
||||
|
||||
/**
|
||||
* @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 includeCustomer(Model $model)
|
||||
{
|
||||
return $this->item($model->customer, new Customer());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
}
|
||||
58
app/Http/Transformers/Item/Item.php
Normal file
58
app/Http/Transformers/Item/Item.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Item;
|
||||
|
||||
use App\Http\Transformers\Setting\Category;
|
||||
use App\Http\Transformers\Setting\Tax;
|
||||
use App\Models\Item\Item as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Item extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['tax', 'category'];
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'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(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeTax(Model $model)
|
||||
{
|
||||
return $this->item($model->tax, new Tax());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Item
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
}
|
||||
27
app/Http/Transformers/Setting/Category.php
Normal file
27
app/Http/Transformers/Setting/Category.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Setting;
|
||||
|
||||
use App\Models\Setting\Category as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Category extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'type' => $model->type,
|
||||
'color' => $model->color,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Transformers/Setting/Currency.php
Normal file
27
app/Http/Transformers/Setting/Currency.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Setting;
|
||||
|
||||
use App\Models\Setting\Currency as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Currency extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'code' => $model->code,
|
||||
'rate' => $model->rate,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Transformers/Setting/Tax.php
Normal file
26
app/Http/Transformers/Setting/Tax.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Setting;
|
||||
|
||||
use App\Models\Setting\Tax as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class Tax extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Model $model)
|
||||
{
|
||||
return [
|
||||
'id' => $model->id,
|
||||
'company_id' => $model->company_id,
|
||||
'name' => $model->name,
|
||||
'rate' => $model->rate,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user