moved transformers
This commit is contained in:
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Auth;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Auth\Permission as Request;
|
||||
use App\Http\Transformers\Auth\Permission as Transformer;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Transformers\Auth\Permission as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Permissions extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Auth;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Auth\Role as Request;
|
||||
use App\Http\Transformers\Auth\Role as Transformer;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Transformers\Auth\Role as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Roles extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Auth;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Auth\User as Request;
|
||||
use App\Http\Transformers\Auth\User as Transformer;
|
||||
use App\Models\Auth\User;
|
||||
use App\Transformers\Auth\User as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Users extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Banking\Account as Request;
|
||||
use App\Http\Transformers\Banking\Account as Transformer;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Transformers\Banking\Account as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Accounts extends ApiController
|
||||
|
@ -4,10 +4,10 @@ namespace App\Http\Controllers\Api\Banking;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Banking\Transfer as Request;
|
||||
use App\Http\Transformers\Banking\Transfer as Transformer;
|
||||
use App\Models\Banking\Transfer;
|
||||
use App\Models\Expense\Payment;
|
||||
use App\Models\Income\Revenue;
|
||||
use App\Transformers\Banking\Transfer as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Transfers extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Companies;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Company\Company as Request;
|
||||
use App\Http\Transformers\Company\Company as Transformer;
|
||||
use App\Models\Company\Company;
|
||||
use App\Transformers\Company\Company as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Companies extends ApiController
|
||||
|
@ -6,7 +6,6 @@ use App\Events\BillCreated;
|
||||
use App\Events\BillUpdated;
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Expense\Bill as Request;
|
||||
use App\Http\Transformers\Expense\Bill as Transformer;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Expense\BillHistory;
|
||||
use App\Models\Expense\BillItem;
|
||||
@ -14,6 +13,7 @@ use App\Models\Expense\BillPayment;
|
||||
use App\Models\Expense\BillStatus;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Transformers\Expense\Bill as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Bills extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Expenses;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Expense\Payment as Request;
|
||||
use App\Http\Transformers\Expense\Payment as Transformer;
|
||||
use App\Models\Expense\Payment;
|
||||
use App\Transformers\Expense\Payment as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Payments extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Expenses;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Expense\Vendor as Request;
|
||||
use App\Http\Transformers\Expense\Vendor as Transformer;
|
||||
use App\Models\Expense\Vendor;
|
||||
use App\Transformers\Expense\Vendor as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Vendors extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Incomes;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Income\Customer as Request;
|
||||
use App\Http\Transformers\Income\Customer as Transformer;
|
||||
use App\Models\Income\Customer;
|
||||
use App\Transformers\Income\Customer as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Customers extends ApiController
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace App\Http\Controllers\Api\Incomes;
|
||||
|
||||
use App\Http\Requests\Income\InvoicePayment as Request;
|
||||
use App\Http\Transformers\Income\InvoicePayments as Transformer;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\InvoiceHistory;
|
||||
use App\Models\Income\InvoicePayment;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\DateTime;
|
||||
use App\Transformers\Income\InvoicePayments as Transformer;
|
||||
use Date;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
@ -6,7 +6,6 @@ use App\Events\InvoiceCreated;
|
||||
use App\Events\InvoiceUpdated;
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Income\Invoice as Request;
|
||||
use App\Http\Transformers\Income\Invoice as Transformer;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Income\InvoiceHistory;
|
||||
use App\Models\Income\InvoiceItem;
|
||||
@ -14,6 +13,7 @@ use App\Models\Income\InvoicePayment;
|
||||
use App\Models\Income\InvoiceTotal;
|
||||
use App\Models\Item\Item;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Transformers\Income\Invoice as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Invoices extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Incomes;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Income\Revenue as Request;
|
||||
use App\Http\Transformers\Income\Revenue as Transformer;
|
||||
use App\Models\Income\Revenue;
|
||||
use App\Transformers\Income\Revenue as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Revenues extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Items;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Item\Item as Request;
|
||||
use App\Http\Transformers\Item\Item as Transformer;
|
||||
use App\Models\Item\Item;
|
||||
use App\Transformers\Item\Item as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Items extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Settings;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Setting\Category as Request;
|
||||
use App\Http\Transformers\Setting\Category as Transformer;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Transformers\Setting\Category as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Categories extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Settings;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Setting\Currency as Request;
|
||||
use App\Http\Transformers\Setting\Currency as Transformer;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Transformers\Setting\Currency as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Currencies extends ApiController
|
||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers\Api\Settings;
|
||||
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Http\Requests\Setting\Tax as Request;
|
||||
use App\Http\Transformers\Setting\Tax as Transformer;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Transformers\Setting\Tax as Transformer;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
|
||||
class Taxes extends ApiController
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Auth;
|
||||
|
||||
use App\Http\Transformers\Company\Company;
|
||||
use App\Models\Auth\User as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class User extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = ['companies', '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 includeCompanies(Model $model)
|
||||
{
|
||||
return $this->collection($model->companies, new Company());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return \League\Fractal\Resource\Collection
|
||||
*/
|
||||
public function includeRoles(Model $model)
|
||||
{
|
||||
return $this->collection($model->roles, new Role());
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?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,
|
||||
'name' => $model->company_name,
|
||||
'email' => $model->company_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,
|
||||
'enabled' => $model->enabled,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Expense;
|
||||
|
||||
use App\Models\Expense\BillTotal as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BillTotals 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,
|
||||
'code' => $model->code,
|
||||
'name' => $model->name,
|
||||
'amount' => $model->amount,
|
||||
'sort_order' => $model->sort_order,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
<?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 mixed
|
||||
*/
|
||||
public function includeVendor(Model $model)
|
||||
{
|
||||
if (!$model->vendor) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Transformers\Income;
|
||||
|
||||
use App\Models\Income\InvoiceTotal as Model;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class InvoiceTotals 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,
|
||||
'code' => $model->code,
|
||||
'name' => $model->name,
|
||||
'amount' => $model->amount,
|
||||
'sort_order' => $model->sort_order,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
'updated_at' => $model->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
<?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 mixed
|
||||
*/
|
||||
public function includeCustomer(Model $model)
|
||||
{
|
||||
if (!$model->customer) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?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 mixed
|
||||
*/
|
||||
public function includeTax(Model $model)
|
||||
{
|
||||
if (!$model->tax) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->tax, new Tax());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function includeCategory(Model $model)
|
||||
{
|
||||
if (!$model->category) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
return $this->item($model->category, new Category());
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?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