v5.0.0 update

This commit is contained in:
Mohit Panjwani
2021-11-30 18:58:19 +05:30
parent d332712c22
commit 082d5cacf2
1253 changed files with 88309 additions and 71741 deletions

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class AbilityCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class AbilityResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'entity_id' => $this->entity_id,
'entity_type' => $this->entity_type,
'only_owned' => $this->only_owned,
'options' => $this->options,
'scope' => $this->scope,
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class AddressCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class AddressResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'address_street_1' => $this->address_street_1,
'address_street_2' => $this->address_street_2,
'city' => $this->city,
'state' => $this->state,
'country_id' => $this->country_id,
'zip' => $this->zip,
'phone' => $this->phone,
'fax' => $this->fax,
'type' => $this->type,
'user_id' => $this->user_id,
'company_id' => $this->company_id,
'customer_id' => $this->customer_id,
'country' => $this->when($this->country()->exists(), function () {
return new CountryResource($this->country);
}),
'user' => $this->when($this->user()->exists(), function () {
return new UserResource($this->user);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CompanyCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CompanyResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'logo' => $this->logo,
'logo_path' => $this->logo_path,
'unique_hash' => $this->unique_hash,
'owner_id' => $this->owner_id,
'address' => $this->when($this->address()->exists(), function () {
return new AddressResource($this->address);
}),
'roles' => RoleResource::collection($this->roles)
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CountryCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CountryResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'phone_code' => $this->phone_code,
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CurrencyCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CurrencyResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'code' => $this->code,
'symbol' => $this->symbol,
'precision' => $this->precision,
'thousand_separator' => $this->thousand_separator,
'decimal_separator' => $this->decimal_separator,
'swap_currency_symbol' => $this->swap_currency_symbol,
'exchange_rate' => $this->exchange_rate
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CustomFieldCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CustomFieldResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'label' => $this->label,
'model_type' => $this->model_type,
'type' => $this->type,
'placeholder' => $this->placeholder,
'options' => $this->options,
'boolean_answer' => $this->boolean_answer,
'date_answer' => $this->date_answer,
'time_answer' => $this->time_answer,
'string_answer' => $this->string_answer,
'number_answer' => $this->number_answer,
'date_time_answer' => $this->date_time_answer,
'is_required' => $this->is_required,
'in_use' => $this->in_use,
'order' => $this->order,
'company_id' => $this->company_id,
'default_answer' => $this->default_answer,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CustomFieldValueCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CustomFieldValueResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'custom_field_valuable_type' => $this->custom_field_valuable_type,
'custom_field_valuable_id' => $this->custom_field_valuable_id,
'type' => $this->type,
'boolean_answer' => $this->boolean_answer,
'date_answer' => $this->date_answer,
'time_answer' => $this->time_answer,
'string_answer' => $this->string_answer,
'number_answer' => $this->number_answer,
'date_time_answer' => $this->date_time_answer,
'custom_field_id' => $this->custom_field_id,
'company_id' => $this->company_id,
'default_answer' => $this->defaultAnswer,
'custom_field' => $this->when($this->customField()->exists(), function () {
return new CustomFieldResource($this->customField);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class CustomerCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class CustomerResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'phone' => $this->phone,
'contact_name' => $this->contact_name,
'company_name' => $this->company_name,
'website' => $this->website,
'enable_portal' => $this->enable_portal,
'currency_id' => $this->currency_id,
'company_id' => $this->company_id,
'estimate_prefix' => $this->estimate_prefix,
'payment_prefix' => $this->payment_prefix,
'invoice_prefix' => $this->invoice_prefix,
'facebook_id' => $this->facebook_id,
'google_id' => $this->google_id,
'github_id' => $this->github_id,
'created_at' => $this->created_at,
'formatted_created_at' => $this->formattedCreatedAt,
'updated_at' => $this->updated_at,
'avatar' => $this->avatar,
'due_amount' => $this->due_amount,
'base_due_amount' => $this->base_due_amount,
'prefix' => $this->prefix,
'billing' => $this->when($this->billingAddress()->exists(), function () {
return new AddressResource($this->billingAddress);
}),
'shipping' => $this->when($this->shippingAddress()->exists(), function () {
return new AddressResource($this->shippingAddress);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class EstimateCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class EstimateItemCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class EstimateItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'discount_type' => $this->discount_type,
'quantity' => $this->quantity,
'unit_name' => $this->unit_name,
'discount' => $this->discount,
'discount_val' => $this->discount_val,
'price' => $this->price,
'tax' => $this->tax,
'total' => $this->total,
'item_id' => $this->item_id,
'estimate_id' => $this->estimate_id,
'company_id' => $this->company_id,
'exchange_rate' => $this->exchange_rate,
'base_discount_val' => $this->base_discount_val,
'base_price' => $this->base_price,
'base_tax' => $this->base_tax,
'base_total' => $this->base_total,
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
];
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class EstimateResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'estimate_date' => $this->estimate_date,
'expiry_date' => $this->expiry_date,
'estimate_number' => $this->estimate_number,
'status' => $this->status,
'reference_number' => $this->reference_number,
'tax_per_item' => $this->tax_per_item,
'discount_per_item' => $this->discount_per_item,
'notes' => $this->notes,
'discount' => $this->discount,
'discount_type' => $this->discount_type,
'discount_val' => $this->discount_val,
'sub_total' => $this->sub_total,
'total' => $this->total,
'tax' => $this->tax,
'unique_hash' => $this->unique_hash,
'creator_id' => $this->creator_id,
'template_name' => $this->template_name,
'customer_id' => $this->customer_id,
'exchange_rate' => $this->exchange_rate,
'base_discount_val' => $this->base_discount_val,
'base_sub_total' => $this->base_sub_total,
'base_total' => $this->base_total,
'base_tax' => $this->base_tax,
'sequence_number' => $this->sequence_number,
'currency_id' => $this->currency_id,
'formatted_expiry_date' => $this->formattedExpiryDate,
'formatted_estimate_date' => $this->formattedEstimateDate,
'estimate_pdf_url' => $this->estimatePdfUrl,
'items' => $this->when($this->items()->exists(), function () {
return EstimateItemResource::collection($this->items);
}),
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'creator' => $this->when($this->creator()->exists(), function () {
return new UserResource($this->creator);
}),
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ExchangeRateLogCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ExchangeRateLogResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'company_id' => $this->company_id,
'base_currency_id' => $this->base_currency_id,
'currency_id' => $this->currency_id,
'exchange_rate' => $this->exchange_rate,
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ExchangeRateProviderCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ExchangeRateProviderResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'key' => $this->key,
'driver' => $this->driver,
'currencies' => $this->currencies,
'driver_config' => $this->driver_config,
'company_id' => $this->company_id,
'active' => $this->active,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ExpenseCategoryCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ExpenseCategoryResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'company_id' => $this->company_id,
'amount' => $this->amount,
'formatted_created_at' => $this->formattedCreatedAt,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ExpenseCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ExpenseResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'expense_date' => $this->expense_date,
'amount' => $this->amount,
'notes' => $this->notes,
'customer_id' => $this->customer_id,
'attachment_receipt_url' => $this->receipt_url,
'attachment_receipt' => $this->receipt,
'attachment_receipt_meta' => $this->receipt_meta,
'company_id' => $this->company_id,
'expense_category_id' => $this->expense_category_id,
'creator_id' => $this->creator_id,
'formatted_expense_date' => $this->formattedExpenseDate,
'formatted_created_at' => $this->formattedCreatedAt,
'exchange_rate' => $this->exchange_rate,
'currency_id' => $this->currency_id,
'base_amount' => $this->base_amount,
'payment_method_id' => $this->payment_method_id,
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'expense_category' => $this->when($this->category()->exists(), function () {
return new ExpenseCategoryResource($this->category);
}),
'creator' => $this->when($this->creator()->exists(), function () {
return new UserResource($this->creator);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
'payment_method' => $this->when($this->paymentMethod()->exists(), function () {
return new PaymentMethodResource($this->paymentMethod);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class FileDiskCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class FileDiskResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'type' => $this->type,
'driver' => $this->driver,
'set_as_default' => $this->set_as_default,
'credentials' => $this->credentials,
'company_id' => $this->company_id,
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class InvoiceCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class InvoiceItemCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'discount_type' => $this->discount_type,
'price' => $this->price,
'quantity' => $this->quantity,
'unit_name' => $this->unit_name,
'discount' => $this->discount,
'discount_val' => $this->discount_val,
'tax' => $this->tax,
'total' => $this->total,
'invoice_id' => $this->invoice_id,
'item_id' => $this->item_id,
'company_id' => $this->company_id,
'base_price' => $this->base_price,
'exchange_rate' => $this->exchange_rate,
'base_discount_val' => $this->base_discount_val,
'base_tax' => $this->base_tax,
'base_total' => $this->base_total,
'recurring_invoice_id' => $this->recurring_invoice_id,
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
];
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'invoice_date' => $this->invoice_date,
'due_date' => $this->due_date,
'invoice_number' => $this->invoice_number,
'reference_number' => $this->reference_number,
'status' => $this->status,
'paid_status' => $this->paid_status,
'tax_per_item' => $this->tax_per_item,
'discount_per_item' => $this->discount_per_item,
'notes' => $this->notes,
'discount_type' => $this->discount_type,
'discount' => $this->discount,
'discount_val' => $this->discount_val,
'sub_total' => $this->sub_total,
'total' => $this->total,
'tax' => $this->tax,
'due_amount' => $this->due_amount,
'sent' => $this->sent,
'viewed' => $this->viewed,
'unique_hash' => $this->unique_hash,
'template_name' => $this->template_name,
'customer_id' => $this->customer_id,
'recurring_invoice_id' => $this->recurring_invoice_id,
'sequence_number' => $this->sequence_number,
'exchange_rate' => $this->exchange_rate,
'base_discount_val' => $this->base_discount_val,
'base_sub_total' => $this->base_sub_total,
'base_total' => $this->base_total,
'creator_id' => $this->creator_id,
'base_tax' => $this->base_tax,
'base_due_amount' => $this->base_due_amount,
'currency_id' => $this->currency_id,
'formatted_created_at' => $this->formattedCreatedAt,
'invoice_pdf_url' => $this->invoicePdfUrl,
'formatted_invoice_date' => $this->formattedInvoiceDate,
'formatted_due_date' => $this->formattedDueDate,
'allow_edit' => $this->allow_edit,
'items' => $this->when($this->items()->exists(), function () {
return InvoiceItemResource::collection($this->items);
}),
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'creator' => $this->when($this->creator()->exists(), function () {
return new UserResource($this->creator);
}),
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class ItemCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ItemResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'price' => $this->price,
'unit_id' => $this->unit_id,
'company_id' => $this->company_id,
'creator_id' => $this->creator_id,
'currency_id' => $this->currency_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'tax_per_item' => $this->tax_per_item,
'formatted_created_at' => $this->formattedCreatedAt,
'unit' => $this->when($this->unit()->exists(), function () {
return new UnitResource($this->unit);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class NoteCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class NoteResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'type' => $this->type,
'name' => $this->name,
'notes' => $this->notes,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class PaymentCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class PaymentMethodCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PaymentMethodResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'company_id' => $this->company_id,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PaymentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'payment_number' => $this->payment_number,
'payment_date' => $this->payment_date,
'notes' => $this->notes,
'amount' => $this->amount,
'unique_hash' => $this->unique_hash,
'invoice_id' => $this->invoice_id,
'company_id' => $this->company_id,
'payment_method_id' => $this->payment_method_id,
'creator_id' => $this->creator_id,
'customer_id' => $this->customer_id,
'exchange_rate' => $this->exchange_rate,
'base_amount' => $this->base_amount,
'currency_id' => $this->currency_id,
'sequence_number' => $this->sequence_number,
'formatted_created_at' => $this->formattedCreatedAt,
'formatted_payment_date' => $this->formattedPaymentDate,
'payment_pdf_url' => $this->paymentPdfUrl,
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'invoice' => $this->when($this->invoice()->exists(), function () {
return new InvoiceResource($this->invoice);
}),
'payment_method' => $this->when($this->paymentMethod()->exists(), function () {
return new PaymentMethodResource($this->paymentMethod);
}),
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class RecurringInvoiceCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class RecurringInvoiceResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'starts_at' => $this->starts_at,
'formatted_starts_at' => $this->formattedStartsAt,
'formatted_created_at' => $this->formattedCreatedAt,
'formatted_next_invoice_at' => $this->formattedNextInvoiceAt,
'formatted_limit_date' => $this->formattedLimitDate,
'send_automatically' => $this->send_automatically,
'customer_id' => $this->customer_id,
'company_id' => $this->company_id,
'creator_id' => $this->creator_id,
'status' => $this->status,
'next_invoice_at' => $this->next_invoice_at,
'frequency' => $this->frequency,
'limit_by' => $this->limit_by,
'limit_count' => $this->limit_count,
'limit_date' => $this->limit_date,
'exchange_rate' => $this->exchange_rate,
'tax_per_item' => $this->tax_per_item,
'discount_per_item' => $this->discount_per_item,
'notes' => $this->notes,
'discount_type' => $this->discount_type,
'discount' => $this->discount,
'discount_val' => $this->discount_val,
'sub_total' => $this->sub_total,
'total' => $this->total,
'tax' => $this->tax,
'due_amount' => $this->due_amount,
'template_name' => $this->template_name,
'fields' => $this->when($this->fields()->exists(), function () {
return CustomFieldValueResource::collection($this->fields);
}),
'items' => $this->when($this->items()->exists(), function () {
return InvoiceItemResource::collection($this->items);
}),
'customer' => $this->when($this->customer()->exists(), function () {
return new CustomerResource($this->customer);
}),
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
'invoices' => $this->when($this->invoices()->exists(), function () {
return InvoiceResource::collection($this->invoices);
}),
'taxes' => $this->when($this->taxes()->exists(), function () {
return TaxResource::collection($this->taxes);
}),
'creator' => $this->when($this->creator()->exists(), function () {
return new UserResource($this->creator);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class RoleCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Crater\Http\Resources;
use Carbon\Carbon;
use Crater\Models\CompanySetting;
use Illuminate\Http\Resources\Json\JsonResource;
class RoleResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'title' => $this->title,
'level' => $this->level,
'formatted_created_at' => $this->getFormattedAt(),
'abilities' => $this->getAbilities()
];
}
public function getFormattedAt()
{
$dateFormat = CompanySetting::getSetting('carbon_date_format', $this->scope);
return Carbon::parse($this->created_at)->format($dateFormat);
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class TaxCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TaxResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'tax_type_id' => $this->tax_type_id,
'invoice_id' => $this->invoice_id,
'estimate_id' => $this->estimate_id,
'invoice_item_id' => $this->invoice_item_id,
'estimate_item_id' => $this->estimate_item_id,
'item_id' => $this->item_id,
'company_id' => $this->company_id,
'name' => $this->name,
'amount' => $this->amount,
'percent' => $this->percent,
'compound_tax' => $this->compound_tax,
'base_amount' => $this->base_amount,
'currency_id' => $this->currency_id,
'recurring_invoice_id' => $this->recurring_invoice_id,
'tax_type' => $this->when($this->taxType()->exists(), function () {
return new TaxTypeResource($this->taxType);
}),
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class TaxTypeCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TaxTypeResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'percent' => $this->percent,
'compound_tax' => $this->compound_tax,
'collective_tax' => $this->collective_tax,
'description' => $this->description,
'company_id' => $this->company_id,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class UnitCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class UnitResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'company_id' => $this->company_id,
'company' => $this->when($this->company()->exists(), function () {
return new CompanyResource($this->company);
}),
];
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection;
class UserCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace Crater\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class UserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'phone' => $this->phone,
'role' => $this->role,
'contact_name' => $this->contact_name,
'company_name' => $this->company_name,
'website' => $this->website,
'enable_portal' => $this->enable_portal,
'currency_id' => $this->currency_id,
'facebook_id' => $this->facebook_id,
'google_id' => $this->google_id,
'github_id' => $this->github_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'avatar' => $this->avatar,
'is_owner' => $this->isOwner(),
'roles' => $this->roles,
'formatted_created_at' => $this->formattedCreatedAt,
'currency' => $this->when($this->currency()->exists(), function () {
return new CurrencyResource($this->currency);
}),
'companies' => $this->when($this->companies()->exists(), function () {
return CompanyResource::collection($this->companies);
})
];
}
}