From bf235ec3902b829c029e59c37fcfeed55b9a32c6 Mon Sep 17 00:00:00 2001 From: Stefan Ninic Date: Wed, 30 Sep 2020 15:45:11 +0200 Subject: [PATCH] Fixed modelClass property --- src/Models/Customer.php | 18 +++++++++--------- src/Models/CustomerContact.php | 5 +++-- src/Models/CustomerGroup.php | 5 +++-- src/Models/CustomerInvoice.php | 25 +++++++++++++------------ src/Models/DeliveryTerm.php | 1 + src/Models/DraftOrder.php | 1 + src/Models/DraftPurchaseOrder.php | 18 +++++++++--------- src/Models/Employee.php | 5 +++-- src/Models/Field.php | 7 ++++--- src/Models/InventoryAdjustment.php | 5 +++-- src/Models/InventoryMovement.php | 5 +++-- src/Models/Layout.php | 5 +++-- src/Models/Location.php | 17 +++++++++-------- src/Models/Lot.php | 18 +++++++++--------- src/Models/Order.php | 18 +++++++++--------- src/Models/OrderNote.php | 5 +++-- src/Models/OrderShipment.php | 26 ++++++++++++++------------ src/Models/PaymentTerm.php | 5 +++-- src/Models/Plugin.php | 19 +++++++++---------- src/Models/Product.php | 3 ++- src/Models/ProductGroup.php | 7 ++++--- src/Models/ProductionOrder.php | 18 +++++++++--------- src/Models/PurchaseOrder.php | 18 +++++++++--------- src/Models/Settings.php | 12 ++++++------ src/Models/Supplier.php | 27 ++++++++++++++------------- src/Models/SupplierGroup.php | 5 +++-- src/Models/SupplierInvoice.php | 1 + src/Models/Variation/Type.php | 21 ++++++++++----------- src/Models/Variation/TypeOption.php | 18 +++++++++--------- src/Models/Variation/Variation.php | 20 ++++++++++---------- src/Models/Webhook.php | 7 ++++--- 31 files changed, 192 insertions(+), 173 deletions(-) diff --git a/src/Models/Customer.php b/src/Models/Customer.php index 9370a46..1e7326d 100644 --- a/src/Models/Customer.php +++ b/src/Models/Customer.php @@ -15,16 +15,16 @@ class Customer extends Model { - protected $entity = 'customers'; - protected $primaryKey = 'number'; + protected $entity = 'customers'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function contacts() - { - return $this->request->handleWithExceptions(function () { + public function contacts() { + return $this->request->handleWithExceptions( function () { - $builder = new CustomerContactBuilder($this->request, $this->url_friendly_id); + $builder = new CustomerContactBuilder( $this->request, $this->url_friendly_id ); - return $builder->get(); - }); - } + return $builder->get(); + } ); + } } \ No newline at end of file diff --git a/src/Models/CustomerContact.php b/src/Models/CustomerContact.php index 5d9ac15..d1658d9 100644 --- a/src/Models/CustomerContact.php +++ b/src/Models/CustomerContact.php @@ -13,6 +13,7 @@ class CustomerContact extends Model { - protected $entity = 'customers/{customer}/contacts'; - protected $primaryKey = 'number'; + protected $entity = 'customers/{customer}/contacts'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/CustomerGroup.php b/src/Models/CustomerGroup.php index c7567b9..ef1b8e1 100644 --- a/src/Models/CustomerGroup.php +++ b/src/Models/CustomerGroup.php @@ -13,6 +13,7 @@ class CustomerGroup extends Model { - protected $entity = 'customer-groups'; - protected $primaryKey = 'number'; + protected $entity = 'customer-groups'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/CustomerInvoice.php b/src/Models/CustomerInvoice.php index a5e2649..a8ec4e6 100644 --- a/src/Models/CustomerInvoice.php +++ b/src/Models/CustomerInvoice.php @@ -14,18 +14,19 @@ class CustomerInvoice extends Model { - protected $entity = 'customer-invoices'; - protected $primaryKey = 'number'; - - /** - * Book customer invoice - * - * @param bool|array $send_email [optional]

- * This parameter indicates should the mail be sent to customer, - * if you send it as array it must be in format like this: - * [ - * "send" => false, - * "body" => "Something", + protected $entity = 'customer-invoices'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; + + /** + * Book customer invoice + * + * @param bool|array $send_email [optional]

+ * This parameter indicates should the mail be sent to customer, + * if you send it as array it must be in format like this: + * [ + * "send" => false, + * "body" => "Something", * "subject" => "YOUR SUBJECT", * "receivers" => [ * "to" => [ "email@here.com"], diff --git a/src/Models/DeliveryTerm.php b/src/Models/DeliveryTerm.php index 1dd52ca..1eeffaa 100644 --- a/src/Models/DeliveryTerm.php +++ b/src/Models/DeliveryTerm.php @@ -9,4 +9,5 @@ class DeliveryTerm extends Model { protected $entity = 'delivery-terms'; protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/DraftOrder.php b/src/Models/DraftOrder.php index 4d45147..9982185 100644 --- a/src/Models/DraftOrder.php +++ b/src/Models/DraftOrder.php @@ -17,6 +17,7 @@ class DraftOrder extends Model { protected $entity = 'orders/drafts'; protected $primaryKey = 'number'; + protected $modelClass = self::class; public function getPDF() { return $this->request->handleWithExceptions( function () { diff --git a/src/Models/DraftPurchaseOrder.php b/src/Models/DraftPurchaseOrder.php index c9ba9fd..4be4528 100644 --- a/src/Models/DraftPurchaseOrder.php +++ b/src/Models/DraftPurchaseOrder.php @@ -7,16 +7,16 @@ class DraftPurchaseOrder extends Model { - protected $entity = 'purchase-orders/drafts'; - protected $primaryKey = 'number'; + protected $entity = 'purchase-orders/drafts'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function getPDF() - { - return $this->request->handleWithExceptions( function () { - $response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf"); + public function getPDF() { + return $this->request->handleWithExceptions( function () { + $response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" ); - return json_decode((string)$response->getBody()); - } ); - } + return json_decode( (string) $response->getBody() ); + } ); + } } diff --git a/src/Models/Employee.php b/src/Models/Employee.php index 5475e6c..9f96a3d 100644 --- a/src/Models/Employee.php +++ b/src/Models/Employee.php @@ -14,6 +14,7 @@ class Employee extends Model { - protected $entity = 'employees'; - protected $primaryKey = 'number'; + protected $entity = 'employees'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/Field.php b/src/Models/Field.php index dd5a3e9..a190aa2 100644 --- a/src/Models/Field.php +++ b/src/Models/Field.php @@ -13,7 +13,8 @@ class Field extends Model { - public $number; - protected $entity = 'fields'; - protected $primaryKey = 'slug'; + public $number; + protected $entity = 'fields'; + protected $primaryKey = 'slug'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/InventoryAdjustment.php b/src/Models/InventoryAdjustment.php index 4f437cf..6657ddf 100644 --- a/src/Models/InventoryAdjustment.php +++ b/src/Models/InventoryAdjustment.php @@ -13,6 +13,7 @@ class InventoryAdjustment extends Model { - protected $entity = 'inventory-adjustments'; - protected $primaryKey = 'id'; + protected $entity = 'inventory-adjustments'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/InventoryMovement.php b/src/Models/InventoryMovement.php index ac1dec9..9db9dfe 100644 --- a/src/Models/InventoryMovement.php +++ b/src/Models/InventoryMovement.php @@ -13,6 +13,7 @@ class InventoryMovement extends Model { - protected $entity = 'inventory-movements'; - protected $primaryKey = 'id'; + protected $entity = 'inventory-movements'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/Layout.php b/src/Models/Layout.php index 4a3a713..94591a6 100644 --- a/src/Models/Layout.php +++ b/src/Models/Layout.php @@ -7,6 +7,7 @@ class Layout extends Model { - protected $entity = 'layouts'; - protected $primaryKey = 'number'; + protected $entity = 'layouts'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/Location.php b/src/Models/Location.php index 4acd278..e1c9d10 100644 --- a/src/Models/Location.php +++ b/src/Models/Location.php @@ -13,13 +13,14 @@ class Location extends Model { - protected $entity = 'locations'; - protected $primaryKey = 'number'; - protected $fillable = [ + protected $entity = 'locations'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; + protected $fillable = [ - "name", - "is_default", - "number", - "parent_id", - ]; + "name", + "is_default", + "number", + "parent_id", + ]; } \ No newline at end of file diff --git a/src/Models/Lot.php b/src/Models/Lot.php index e377b1f..f532a32 100644 --- a/src/Models/Lot.php +++ b/src/Models/Lot.php @@ -13,19 +13,19 @@ class Lot extends Model { - public $number; - protected $entity = 'lots'; - protected $primaryKey = 'number'; + public $number; + protected $entity = 'lots'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function variations( $variation_id = 1001 ) - { - return $this->request->handleWithExceptions( function () use ( $variation_id ) { + public function variations( $variation_id = 1001 ) { + return $this->request->handleWithExceptions( function () use ( $variation_id ) { - $response = $this->request->client->get("variations/{$this->url_friendly_id}/variation-matrix"); + $response = $this->request->client->get( "variations/{$this->url_friendly_id}/variation-matrix" ); - return json_decode((string)$response->getBody()); - } ); + return json_decode( (string) $response->getBody() ); + } ); } public function location() diff --git a/src/Models/Order.php b/src/Models/Order.php index d1d7ed2..0ecb3a9 100644 --- a/src/Models/Order.php +++ b/src/Models/Order.php @@ -16,18 +16,18 @@ class Order extends Model { - protected $entity = 'orders'; - protected $primaryKey = 'number'; + protected $entity = 'orders'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function getPDF() - { - return $this->request->handleWithExceptions( function () { - $response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf"); + public function getPDF() { + return $this->request->handleWithExceptions( function () { + $response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" ); - return json_decode((string)$response->getBody()); - } ); - } + return json_decode( (string) $response->getBody() ); + } ); + } public function reopen() { diff --git a/src/Models/OrderNote.php b/src/Models/OrderNote.php index 995b417..f782b2a 100644 --- a/src/Models/OrderNote.php +++ b/src/Models/OrderNote.php @@ -6,7 +6,8 @@ class OrderNote extends Model { - protected $entity = 'orders/:number/notes'; - protected $primaryKey = 'id'; + protected $entity = 'orders/:number/notes'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; } diff --git a/src/Models/OrderShipment.php b/src/Models/OrderShipment.php index 7571ef6..0932138 100644 --- a/src/Models/OrderShipment.php +++ b/src/Models/OrderShipment.php @@ -13,18 +13,20 @@ class OrderShipment extends Model { - protected $entity = 'order-shipments'; - protected $primaryKey = 'id'; - - /** - * Mark shipment as shipped - * - * @param bool $pick Mark all shipment lines as picked - * @return mixed - * @throws \Rackbeat\Exceptions\RackbeatClientException - * @throws \Rackbeat\Exceptions\RackbeatRequestException - */ - public function markShipped($pick = true) + protected $entity = 'order-shipments'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; + + /** + * Mark shipment as shipped + * + * @param bool $pick Mark all shipment lines as picked + * + * @return mixed + * @throws \Rackbeat\Exceptions\RackbeatClientException + * @throws \Rackbeat\Exceptions\RackbeatRequestException + */ + public function markShipped( $pick = true ) { return $this->request->handleWithExceptions(function () use ($pick) { diff --git a/src/Models/PaymentTerm.php b/src/Models/PaymentTerm.php index 653343f..5c7f9b2 100644 --- a/src/Models/PaymentTerm.php +++ b/src/Models/PaymentTerm.php @@ -13,6 +13,7 @@ class PaymentTerm extends Model { - protected $entity = 'payment-terms'; - protected $primaryKey = 'number'; + protected $entity = 'payment-terms'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/Plugin.php b/src/Models/Plugin.php index 7d3e8b6..fd9bbf4 100644 --- a/src/Models/Plugin.php +++ b/src/Models/Plugin.php @@ -15,16 +15,15 @@ class Plugin extends Model { - protected $entity = 'user-account-plugins'; - protected $primaryKey = 'id'; + protected $entity = 'user-account-plugins'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; - public function delete() - { - throw new MethodNotImplemented(); - } + public function delete() { + throw new MethodNotImplemented(); + } - public function update( $data = [] ) - { - throw new MethodNotImplemented(); - } + public function update( $data = [] ) { + throw new MethodNotImplemented(); + } } \ No newline at end of file diff --git a/src/Models/Product.php b/src/Models/Product.php index e9620a2..f8e3864 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -17,6 +17,7 @@ class Product extends Model public $number; protected $entity = 'products'; protected $primaryKey = 'number'; + protected $modelClass = self::class; public function inventoryMatrix( $location_id = null, array $filter = null ) { return $this->request->handleWithExceptions( function () use ( $location_id, $filter ) { @@ -24,7 +25,7 @@ public function inventoryMatrix( $location_id = null, array $filter = null ) { $query = ''; // We need to use location filter if user has provided any - if ( !is_null( $location_id ) ) { + if ( ! is_null( $location_id ) ) { $query .= '?location_id=' . $location_id; } diff --git a/src/Models/ProductGroup.php b/src/Models/ProductGroup.php index a480351..0453e81 100644 --- a/src/Models/ProductGroup.php +++ b/src/Models/ProductGroup.php @@ -13,7 +13,8 @@ class ProductGroup extends Model { - public $number; - protected $entity = 'product-groups'; - protected $primaryKey = 'number'; + public $number; + protected $entity = 'product-groups'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/ProductionOrder.php b/src/Models/ProductionOrder.php index 4ced975..1ff85e0 100644 --- a/src/Models/ProductionOrder.php +++ b/src/Models/ProductionOrder.php @@ -13,16 +13,16 @@ class ProductionOrder extends Model { - protected $entity = 'production-orders'; - protected $primaryKey = 'number'; + protected $entity = 'production-orders'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function getPDF() - { - return $this->request->handleWithExceptions( function () { - $response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf"); + public function getPDF() { + return $this->request->handleWithExceptions( function () { + $response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" ); - return json_decode((string)$response->getBody()); - } ); - } + return json_decode( (string) $response->getBody() ); + } ); + } } diff --git a/src/Models/PurchaseOrder.php b/src/Models/PurchaseOrder.php index b6e68f3..134cd23 100644 --- a/src/Models/PurchaseOrder.php +++ b/src/Models/PurchaseOrder.php @@ -7,18 +7,18 @@ class PurchaseOrder extends Model { - protected $entity = 'purchase-orders'; - protected $primaryKey = 'number'; + protected $entity = 'purchase-orders'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function getPDF() - { - return $this->request->handleWithExceptions( function () { - $response = $this->request->client->get("{$this->entity}/{$this->url_friendly_id}.pdf"); + public function getPDF() { + return $this->request->handleWithExceptions( function () { + $response = $this->request->client->get( "{$this->entity}/{$this->url_friendly_id}.pdf" ); - return json_decode((string)$response->getBody()); - } ); - } + return json_decode( (string) $response->getBody() ); + } ); + } public function reopen() { diff --git a/src/Models/Settings.php b/src/Models/Settings.php index 0db16e2..4df97e2 100644 --- a/src/Models/Settings.php +++ b/src/Models/Settings.php @@ -15,12 +15,12 @@ class Settings extends Model { - protected $entity = 'settings'; - protected $primaryKey = 'identifier'; + protected $entity = 'settings'; + protected $primaryKey = 'identifier'; + protected $modelClass = self::class; - public function delete() - { - throw new MethodNotImplemented(); - } + public function delete() { + throw new MethodNotImplemented(); + } } \ No newline at end of file diff --git a/src/Models/Supplier.php b/src/Models/Supplier.php index b4e30f5..2cb3fd2 100644 --- a/src/Models/Supplier.php +++ b/src/Models/Supplier.php @@ -13,21 +13,22 @@ class Supplier extends Model { - public $number; - public $company_name; + public $number; + public $company_name; - protected $entity = 'suppliers'; - protected $primaryKey = 'number'; - protected $fillable = [ + protected $entity = 'suppliers'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; + protected $fillable = [ - "number", - "company_name", - "company_vat", - "address_street", - "address_street2", - "address_city", - "address_zipcode", - "address_country", + "number", + "company_name", + "company_vat", + "address_street", + "address_street2", + "address_city", + "address_zipcode", + "address_country", "contact_email", "contact_phone", "locale", diff --git a/src/Models/SupplierGroup.php b/src/Models/SupplierGroup.php index 6dc0a04..bb160b9 100644 --- a/src/Models/SupplierGroup.php +++ b/src/Models/SupplierGroup.php @@ -13,6 +13,7 @@ class SupplierGroup extends Model { - protected $entity = 'supplier-groups'; - protected $primaryKey = 'number'; + protected $entity = 'supplier-groups'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file diff --git a/src/Models/SupplierInvoice.php b/src/Models/SupplierInvoice.php index 7182b4e..1b79e13 100644 --- a/src/Models/SupplierInvoice.php +++ b/src/Models/SupplierInvoice.php @@ -16,6 +16,7 @@ class SupplierInvoice extends Model protected $entity = 'supplier-invoices'; protected $primaryKey = 'number'; + protected $modelClass = self::class; /** * Book supplier invoice diff --git a/src/Models/Variation/Type.php b/src/Models/Variation/Type.php index fa7dcfa..9dd399e 100644 --- a/src/Models/Variation/Type.php +++ b/src/Models/Variation/Type.php @@ -15,20 +15,19 @@ class Type extends Model { - public $id; - protected $entity = 'variations/:variation_number/types'; - protected $primaryKey = 'id'; - protected $typeOptionModel = TypeOption::class; + public $id; + protected $entity = 'variations/:variation_number/types'; + protected $primaryKey = 'id'; + protected $typeOptionModel = TypeOption::class; + protected $modelClass = self::class; - public function __construct( Request $request, $data = [] ) - { - parent::__construct( $request, $data ); + public function __construct( Request $request, $data = [] ) { + parent::__construct( $request, $data ); - $this->entity = str_replace( ':variation_number', $this->variation_id, $this->entity ); - } + $this->entity = str_replace( ':variation_number', $this->variation_id, $this->entity ); + } - public function options() - { + public function options() { $options = new TypeOptionBuilder( $this->request ); $old_entity = $options->getEntity(); $new_entity = $options->setEntity(str_replace(':variation_number', $this->variation_id, $old_entity)); diff --git a/src/Models/Variation/TypeOption.php b/src/Models/Variation/TypeOption.php index 4a4df67..2d344f3 100644 --- a/src/Models/Variation/TypeOption.php +++ b/src/Models/Variation/TypeOption.php @@ -14,15 +14,15 @@ class TypeOption extends Model { - public $id; - protected $entity = 'variations/:variation_number/types/:type_number/options'; - protected $primaryKey = 'id'; + public $id; + protected $entity = 'variations/:variation_number/types/:type_number/options'; + protected $primaryKey = 'id'; + protected $modelClass = self::class; - public function __construct( Request $request, $data = [] ) - { - parent::__construct( $request, $data ); + public function __construct( Request $request, $data = [] ) { + parent::__construct( $request, $data ); - $this->entity = str_replace( ':variation_number', $this->variation_id, $this->entity ); - $this->entity = str_replace( ':type_number', $this->type_id, $this->entity ); - } + $this->entity = str_replace( ':variation_number', $this->variation_id, $this->entity ); + $this->entity = str_replace( ':type_number', $this->type_id, $this->entity ); + } } \ No newline at end of file diff --git a/src/Models/Variation/Variation.php b/src/Models/Variation/Variation.php index f9b08e5..2337485 100644 --- a/src/Models/Variation/Variation.php +++ b/src/Models/Variation/Variation.php @@ -14,16 +14,16 @@ class Variation extends Model { - public $number; - protected $entity = 'variations'; - protected $primaryKey = 'number'; + public $number; + protected $entity = 'variations'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; - public function types() - { - $types = new TypeBuilder( $this->request ); - $old_entity = $types->getEntity(); - $types->setEntity(str_replace(':variation_number', $this->url_friendly_id, $old_entity)); + public function types() { + $types = new TypeBuilder( $this->request ); + $old_entity = $types->getEntity(); + $types->setEntity( str_replace( ':variation_number', $this->url_friendly_id, $old_entity ) ); - return $types; - } + return $types; + } } \ No newline at end of file diff --git a/src/Models/Webhook.php b/src/Models/Webhook.php index d8a4aa9..0e4adf0 100644 --- a/src/Models/Webhook.php +++ b/src/Models/Webhook.php @@ -13,7 +13,8 @@ class Webhook extends Model { - public $number; - protected $entity = 'webhooks'; - protected $primaryKey = 'number'; + public $number; + protected $entity = 'webhooks'; + protected $primaryKey = 'number'; + protected $modelClass = self::class; } \ No newline at end of file