diff --git a/composer.json b/composer.json index 7fe23c407..3db3c622d 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "intervention/image": "^2.4", "intervention/imagecache": "^2.3", "kalnoy/nestedset": "^4.3", + "konekt/concord": "^1.2", "laravel/framework": "5.6.*", "laravel/tinker": "^1.0", "nwidart/laravel-modules": "^3.2", @@ -34,7 +35,7 @@ "webkul/laravel-ui": "self.version", "webkul/laravel-core": "self.version", "webkul/laravel-attribute": "self.version", - "webkul/laravel-cart": "self.version", + "webkul/laravel-checkout": "self.version", "webkul/laravel-customer": "self.version", "webkul/laravel-inventory": "self.version", "webkul/laravel-category": "self.version", @@ -56,7 +57,7 @@ "Webkul\\Admin\\": "packages/Webkul/Admin/src", "Webkul\\Ui\\": "packages/Webkul/Ui/src", "Webkul\\Category\\": "packages/Webkul/Category/src", - "Webkul\\Cart\\": "packages/Webkul/Cart/src", + "Webkul\\Checkout\\": "packages/Webkul/Checkout/src", "Webkul\\Attribute\\": "packages/Webkul/Attribute/src", "Webkul\\Shop\\": "packages/Webkul/Shop/src", "Webkul\\Core\\": "packages/Webkul/Core/src", diff --git a/composer.lock b/composer.lock index ec992ced6..d3653b9fa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c0c2a23aa2502c590b2ccf7975329ce1", + "content-hash": "762c5c196d8a9a7814101fd53d60b1cf", "packages": [ { "name": "commerceguys/intl", @@ -922,6 +922,173 @@ ], "time": "2018-02-04T08:47:55+00:00" }, + { + "name": "konekt/concord", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/artkonekt/concord.git", + "reference": "7379f847fe1e90f9b71ce3f435dd9617ab8dfff5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/artkonekt/concord/zipball/7379f847fe1e90f9b71ce3f435dd9617ab8dfff5", + "reference": "7379f847fe1e90f9b71ce3f435dd9617ab8dfff5", + "shasum": "" + }, + "require": { + "illuminate/console": "~5.4", + "illuminate/support": "~5.4", + "konekt/enum": "~2.1", + "konekt/enum-eloquent": "^1.1.3", + "php": ">=7.0.0" + }, + "require-dev": { + "orchestra/testbench": "^3.4.2", + "phpunit/phpunit": "6.0 - 7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + }, + "laravel": { + "providers": [ + "Konekt\\Concord\\ConcordServiceProvider" + ], + "aliases": { + "Concord": "Konekt\\Concord\\Facades\\Concord", + "Helper": "Konekt\\Concord\\Facades\\Helper" + } + } + }, + "autoload": { + "psr-4": { + "Konekt\\Concord\\": "src" + }, + "files": [ + "src/Support/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Attila Fulop", + "homepage": "https://github.com/fulopattila122" + } + ], + "description": "Concord is a Laravel Extension for building modular Laravel Applications", + "time": "2018-08-11T08:25:39+00:00" + }, + { + "name": "konekt/enum", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/artkonekt/enum.git", + "reference": "ab37d89e1a6f88a76f25c6dd88b56b8892de86f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/artkonekt/enum/zipball/ab37d89e1a6f88a76f25c6dd88b56b8892de86f2", + "reference": "ab37d89e1a6f88a76f25c6dd88b56b8892de86f2", + "shasum": "" + }, + "require": { + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "6.2 - 7.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Konekt\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Attila Fulop", + "homepage": "https://github.com/fulopattila122" + } + ], + "description": "SPL inspired PHP enum class implementation", + "keywords": [ + "artkonekt", + "enum", + "konekt" + ], + "time": "2018-06-09T13:03:01+00:00" + }, + { + "name": "konekt/enum-eloquent", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/artkonekt/enum-eloquent.git", + "reference": "f67c981d549f69cddb9956ef51d16267c050a0c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/artkonekt/enum-eloquent/zipball/f67c981d549f69cddb9956ef51d16267c050a0c9", + "reference": "f67c981d549f69cddb9956ef51d16267c050a0c9", + "shasum": "" + }, + "require": { + "illuminate/database": "5.*", + "konekt/enum": "^2.0.2", + "php": ">=7.0.0" + }, + "require-dev": { + "illuminate/events": "5.*", + "phpunit/phpunit": "~6.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Konekt\\Enum\\Eloquent\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Attila Fulop", + "homepage": "https://github.com/fulopattila122" + } + ], + "description": "Enum attribute casting for Eloquent models", + "keywords": [ + "artkonekt", + "eloquent", + "enum", + "konekt", + "laravel" + ], + "time": "2017-12-08T17:57:42+00:00" + }, { "name": "laravel/framework", "version": "v5.6.29", diff --git a/config/app.php b/config/app.php index 56e8a7b5a..a42f0875f 100644 --- a/config/app.php +++ b/config/app.php @@ -175,6 +175,7 @@ return [ //Repository Prettus\Repository\Providers\RepositoryServiceProvider::class, + Konekt\Concord\ConcordServiceProvider::class, //Webkul packages Webkul\User\Providers\UserServiceProvider::class, @@ -188,7 +189,7 @@ return [ Webkul\Inventory\Providers\InventoryServiceProvider::class, Webkul\Product\Providers\ProductServiceProvider::class, Webkul\Theme\Providers\ThemeServiceProvider::class, - Webkul\Cart\Providers\CartServiceProvider::class, + Webkul\Checkout\Providers\CartServiceProvider::class, Webkul\Shipping\Providers\ShippingServiceProvider::class, Webkul\Payment\Providers\PaymentServiceProvider::class, Webkul\Sales\Providers\SalesServiceProvider::class, @@ -243,7 +244,7 @@ return [ 'Datagrid' => Webkul\Ui\DataGrid\Facades\DataGrid::class, 'ProductGrid' => Webkul\Ui\DataGrid\Facades\ProductGrid::class, 'Image' => Intervention\Image\Facades\Image::class, - 'Cart' => Webkul\Cart\Facades\Cart::class, + 'Cart' => Webkul\Checkout\Facades\Cart::class, 'Core' => Webkul\Core\Facades\Core::class ], diff --git a/packages/Webkul/Cart/src/Http/Controllers/Controller.php b/packages/Webkul/Cart/src/Http/Controllers/Controller.php deleted file mode 100644 index 3b56110cc..000000000 --- a/packages/Webkul/Cart/src/Http/Controllers/Controller.php +++ /dev/null @@ -1,13 +0,0 @@ -app->bind('cart', 'Webkul\Cart\Cart'); + $this->app->bind('cart', 'Webkul\Checkout\Cart'); } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php b/packages/Webkul/Checkout/src/Providers/ComposerServiceProvider.php similarity index 87% rename from packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php rename to packages/Webkul/Checkout/src/Providers/ComposerServiceProvider.php index 3f62d51c7..73007f3fa 100644 --- a/packages/Webkul/Cart/src/Providers/ComposerServiceProvider.php +++ b/packages/Webkul/Checkout/src/Providers/ComposerServiceProvider.php @@ -1,6 +1,6 @@ increments('id'); + $table->string('increment_id'); + + $table->boolean('is_guest')->nullable(); + $table->string('customer_email')->nullable(); + $table->string('customer_first_name')->nullable(); + $table->string('customer_last_name')->nullable(); + + $table->string('shipping_method')->nullable(); + $table->string('shipping_description')->nullable(); + $table->string('coupon_code')->nullable(); + $table->boolean('is_gift')->default(0); + + $table->integer('total_item_count')->nullable(); + $table->integer('total_qty_ordered')->nullable(); + + $table->string('base_currency_code')->nullable(); + $table->string('channel_currency_code')->nullable(); + $table->string('order_currency_code')->nullable(); + + $table->decimal('grand_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_grand_total', 12, 4)->default(0)->nullable(); + $table->decimal('grand_total_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_grand_total_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('grand_total_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_grand_total_refunded', 12, 4)->default(0)->nullable(); + + $table->decimal('sub_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_sub_total', 12, 4)->default(0)->nullable(); + $table->decimal('sub_total_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_sub_total_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('sub_total_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_sub_total_refunded', 12, 4)->default(0)->nullable(); + + $table->decimal('discount_percent', 12, 4)->default(0)->nullable(); + $table->decimal('discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('discount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('discount_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_refunded', 12, 4)->default(0)->nullable(); + + $table->decimal('tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('tax_amount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('tax_amount_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount_refunded', 12, 4)->default(0)->nullable(); + + $table->decimal('shipping_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_shipping_amount', 12, 4)->default(0)->nullable(); + $table->decimal('shipping_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_shipping_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('shipping_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_shipping_refunded', 12, 4)->default(0)->nullable(); + + $table->integer('customer_id')->unsigned()->nullable(); + $table->string('customer_type')->nullable(); + $table->foreign('customer_id')->references('id')->on('customers')->onDelete('set null'); + $table->integer('channel_id')->unsigned()->nullable(); + $table->string('channel_type')->nullable(); + $table->foreign('channel_id')->references('id')->on('channels')->onDelete('set null'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('orders'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113207_create_order_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113207_create_order_items_table.php new file mode 100644 index 000000000..930724305 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113207_create_order_items_table.php @@ -0,0 +1,78 @@ +increments('id'); + $table->string('sku')->nullable(); + $table->string('type')->nullable(); + $table->string('name')->nullable(); + $table->string('coupon_code')->nullable(); + + $table->decimal('weight', 12,4)->default(0)->nullable(); + $table->decimal('total_weight', 12,4)->default(0)->nullable(); + + $table->integer('qty_ordered')->default(0)->nullable(); + $table->integer('qty_shipped')->default(0)->nullable(); + $table->integer('qty_invoiced')->default(0)->nullable(); + $table->integer('qty_refunded')->default(0)->nullable(); + + $table->decimal('price', 12,4)->default(0); + $table->decimal('base_price', 12,4)->default(0); + + $table->decimal('total', 12,4)->default(0); + $table->decimal('base_total', 12,4)->default(0); + $table->decimal('total_invoiced', 12,4)->default(0); + $table->decimal('base_total_invoiced', 12,4)->default(0); + $table->decimal('amount_refunded', 12,4)->default(0); + $table->decimal('base_amount_refunded', 12,4)->default(0); + + $table->decimal('discount_percent', 12, 4)->default(0)->nullable(); + $table->decimal('discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('discount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('discount_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_refunded', 12, 4)->default(0)->nullable(); + + $table->decimal('tax_percent', 12, 4)->default(0)->nullable(); + $table->decimal('tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('tax_amount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount_invoiced', 12, 4)->default(0)->nullable(); + $table->decimal('tax_amount_refunded', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount_refunded', 12, 4)->default(0)->nullable(); + + $table->integer('product_id')->unsigned()->nullable(); + $table->string('product_type')->nullable(); + $table->integer('order_id')->unsigned()->nullable(); + $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign('parent_id')->references('id')->on('order_items')->onDelete('cascade'); + + $table->json('additional')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('order_items'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113405_create_order_address_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113405_create_order_address_table.php new file mode 100644 index 000000000..7083fc8ca --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113405_create_order_address_table.php @@ -0,0 +1,46 @@ +increments('id'); + $table->string('first_name'); + $table->string('last_name'); + $table->string('email'); + $table->string('address1'); + $table->string('address2')->nullable(); + $table->string('country'); + $table->string('state'); + $table->string('city'); + $table->integer('postcode'); + $table->string('phone'); + $table->string('address_type'); + $table->integer('order_id')->unsigned(); + $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); + $table->integer('customer_id')->unsigned()->nullable(); + $table->foreign('customer_id')->references('id')->on('customers')->onDelete('set null'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('order_address'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115022_create_shipments_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115022_create_shipments_table.php new file mode 100644 index 000000000..8e7357c02 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115022_create_shipments_table.php @@ -0,0 +1,46 @@ +increments('id'); + $table->string('status')->nullable(); + + $table->integer('total_qty')->nullable(); + $table->integer('total_weight')->nullable(); + $table->string('carrier_code')->nullable(); + $table->string('carrier_title')->nullable(); + $table->text('track_number')->nullable(); + $table->boolean('email_sent')->default(0); + + $table->integer('customer_id')->unsigned()->nullable(); + $table->string('customer_type')->nullable(); + $table->integer('order_id')->unsigned(); + $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); + $table->integer('order_address_id')->unsigned()->nullable(); + $table->foreign('order_address_id')->references('id')->on('order_address')->onDelete('set null'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('shipments'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php new file mode 100644 index 000000000..2d92a3802 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php @@ -0,0 +1,50 @@ +increments('id'); + $table->string('name')->nullable(); + $table->string('description')->nullable(); + $table->string('sku')->nullable(); + $table->integer('qty')->nullable(); + $table->integer('weight')->nullable(); + + $table->decimal('price', 12, 4)->default(0)->nullable(); + $table->decimal('base_price', 12, 4)->default(0)->nullable(); + $table->decimal('base_total', 12, 4)->default(0)->nullable(); + + $table->integer('product_id')->unsigned()->nullable(); + $table->string('product_type')->nullable(); + $table->integer('order_item_id')->unsigned()->nullable(); + $table->integer('shipment_id')->unsigned(); + $table->foreign('shipment_id')->references('id')->on('shipments')->onDelete('cascade'); + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign('parent_id')->references('id')->on('shipment_items')->onDelete('cascade'); + + $table->json('additional')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('shipment_items'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php new file mode 100644 index 000000000..8499953d8 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php @@ -0,0 +1,68 @@ +increments('id'); + $table->string('increment_id'); + $table->string('state')->nullable(); + $table->boolean('email_sent')->default(0); + $table->string('shipping_method')->nullable(); + $table->string('shipping_description')->nullable(); + $table->string('coupon_code')->nullable(); + $table->boolean('is_gift')->default(0); + + $table->integer('total_item_count')->nullable(); + $table->integer('total_qty_ordered')->nullable(); + + $table->string('base_currency_code')->nullable(); + $table->string('channel_currency_code')->nullable(); + $table->string('order_currency_code')->nullable(); + + $table->decimal('sub_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_sub_total', 12, 4)->default(0)->nullable(); + + $table->decimal('grand_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_grand_total', 12, 4)->default(0)->nullable(); + + $table->decimal('shipping_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_shipping_amount', 12, 4)->default(0)->nullable(); + + $table->decimal('tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12, 4)->default(0)->nullable(); + + $table->decimal('discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_amount', 12, 4)->default(0)->nullable(); + + $table->integer('customer_id')->unsigned()->nullable(); + $table->string('customer_type')->nullable(); + $table->integer('channel_id')->unsigned()->nullable(); + $table->string('channel_type')->nullable(); + $table->foreign('channel_id')->references('id')->on('channels')->onDelete('set null'); + $table->integer('order_address_id')->unsigned()->nullable(); + $table->foreign('order_address_id')->references('id')->on('order_address')->onDelete('set null'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoices'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php new file mode 100644 index 000000000..93b98a143 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php @@ -0,0 +1,54 @@ +increments('id'); + $table->string('name')->nullable(); + $table->string('description')->nullable(); + $table->string('sku')->nullable(); + $table->integer('qty')->nullable(); + + $table->decimal('price', 12,4)->default(0); + $table->decimal('base_price', 12,4)->default(0); + + $table->decimal('total', 12,4)->default(0); + $table->decimal('base_total', 12,4)->default(0); + + $table->decimal('tax_amount', 12,4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12,4)->default(0)->nullable(); + + $table->integer('product_id')->unsigned()->nullable(); + $table->string('product_type')->nullable(); + $table->integer('order_item_id')->unsigned()->nullable(); + $table->integer('invoice_id')->unsigned()->nullable(); + $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign('parent_id')->references('id')->on('shipment_items')->onDelete('cascade'); + + $table->json('additional')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoice_items'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/Invoice.php b/packages/Webkul/Sales/src/Models/Invoice.php new file mode 100644 index 000000000..35a8d782d --- /dev/null +++ b/packages/Webkul/Sales/src/Models/Invoice.php @@ -0,0 +1,72 @@ +hasMany(InvoiceItemProxy::modelClass())->whereNull('parent_id'); + } + + /** + * Get the customer record associated with the invoice. + */ + public function customer() + { + return $this->morphTo(); + } + + /** + * Get the channel record associated with the invoice. + */ + public function channel() + { + return $this->morphTo(); + } + + /** + * Get the addresses for the invoice. + */ + public function addresses() + { + return $this->hasMany(OrderAddressProxy::modelClass()); + } + + /** + * Get the biling address for the invoice. + */ + public function billing_address() + { + return $this->addresses()->where('address_type', 'billing'); + } + + /** + * Get billing address for the invoice. + */ + public function getBillingAddressAttribute() + { + return $this->billing_address()->first(); + } + + /** + * Get the shipping address for the invoice. + */ + public function shipping_address() + { + return $this->addresses()->where('address_type', 'shipping'); + } + + /** + * Get shipping address for the invoice. + */ + public function getShippingAddressAttribute() + { + return $this->shipping_address()->first(); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/InvoiceItem.php b/packages/Webkul/Sales/src/Models/InvoiceItem.php new file mode 100644 index 000000000..908096afd --- /dev/null +++ b/packages/Webkul/Sales/src/Models/InvoiceItem.php @@ -0,0 +1,41 @@ +belongsTo(InvoiceProxy::modelClass()); + } + + /** + * Get the order item record associated with the invoice item. + */ + public function order_item() + { + return $this->belongsTo(OrderItemProxy::modelClass()); + } + + /** + * Get the invoice record associated with the invoice item. + */ + public function product() + { + return $this->morphTo(); + } + + /** + * Get the child item record associated with the invoice item. + */ + public function child() + { + return $this->belongsTo(InvoiceItemProxy::modelClass(), 'parent_id'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/InvoiceItemProxy.php b/packages/Webkul/Sales/src/Models/InvoiceItemProxy.php new file mode 100644 index 000000000..9d7dc640b --- /dev/null +++ b/packages/Webkul/Sales/src/Models/InvoiceItemProxy.php @@ -0,0 +1,10 @@ +hasMany(CartItemProxy::modelClass())->whereNull('parent_id'); + } + + /** + * Get the order shipments record associated with the order. + */ + public function shipments() { + return $this->hasMany(ShipmentProxy::modelClass()); + } + + /** + * Get the order invoices record associated with the order. + */ + public function invoices() { + return $this->hasMany(InvoiceProxy::modelClass()); + } + + /** + * Get the customer record associated with the order. + */ + public function customer() + { + return $this->morphTo(); + } + + /** + * Get the addresses for the order. + */ + public function addresses() + { + return $this->hasMany(OrderAddressProxy::modelClass()); + } + + /** + * Get the biling address for the order. + */ + public function billing_address() + { + return $this->addresses()->where('address_type', 'billing'); + } + + /** + * Get billing address for the order. + */ + public function getBillingAddressAttribute() + { + return $this->billing_address()->first(); + } + + /** + * Get the shipping address for the order. + */ + public function shipping_address() + { + return $this->addresses()->where('address_type', 'shipping'); + } + + /** + * Get shipping address for the order. + */ + public function getShippingAddressAttribute() + { + return $this->shipping_address()->first(); + } + + /** + * Get the channel record associated with the order. + */ + public function channel() + { + return $this->morphTo(); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/OrderAddress.php b/packages/Webkul/Sales/src/Models/OrderAddress.php new file mode 100644 index 000000000..e34b97b0e --- /dev/null +++ b/packages/Webkul/Sales/src/Models/OrderAddress.php @@ -0,0 +1,28 @@ +first_name . ' ' . $this->last_name; + } + + /** + * Get the customer record associated with the order. + */ + public function customer() + { + return $this->belongsTo(Customer::class); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/OrderAddressProxy.php b/packages/Webkul/Sales/src/Models/OrderAddressProxy.php new file mode 100644 index 000000000..5adb02378 --- /dev/null +++ b/packages/Webkul/Sales/src/Models/OrderAddressProxy.php @@ -0,0 +1,10 @@ +belongsTo(OrderProxy::modelClass()); + } + + /** + * Get the order record associated with the order item. + */ + public function product() + { + return $this->morphTo(); + } + + /** + * Get the child item record associated with the order item. + */ + public function child() + { + return $this->belongsTo(OrderItemProxy::modelClass(), 'parent_id'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/OrderItemProxy.php b/packages/Webkul/Sales/src/Models/OrderItemProxy.php new file mode 100644 index 000000000..2a50233ff --- /dev/null +++ b/packages/Webkul/Sales/src/Models/OrderItemProxy.php @@ -0,0 +1,10 @@ +hasMany(ShipmentItemProxy::modelClass())->whereNull('parent_id'); + } + + /** + * Get the customer record associated with the shipment. + */ + public function customer() + { + return $this->morphTo(); + } + + /** + * Get the addresses for the shipment. + */ + public function addresses() + { + return $this->hasMany(OrderAddressProxy::modelClass()); + } + + /** + * Get the biling address for the shipment. + */ + public function billing_address() + { + return $this->addresses()->where('address_type', 'billing'); + } + + /** + * Get billing address for the shipment. + */ + public function getBillingAddressAttribute() + { + return $this->billing_address()->first(); + } + + /** + * Get the shipping address for the shipment. + */ + public function shipping_address() + { + return $this->addresses()->where('address_type', 'shipping'); + } + + /** + * Get shipping address for the shipment. + */ + public function getShippingAddressAttribute() + { + return $this->shipping_address()->first(); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/ShipmentItem.php b/packages/Webkul/Sales/src/Models/ShipmentItem.php new file mode 100644 index 000000000..2b849ee69 --- /dev/null +++ b/packages/Webkul/Sales/src/Models/ShipmentItem.php @@ -0,0 +1,41 @@ +belongsTo(ShipmentProxy::modelClass()); + } + + /** + * Get the order item record associated with the shipment item. + */ + public function order_item() + { + return $this->belongsTo(OrderItemProxy::modelClass()); + } + + /** + * Get the shipment record associated with the shipment item. + */ + public function product() + { + return $this->morphTo(); + } + + /** + * Get the child item record associated with the shipment item. + */ + public function child() + { + return $this->belongsTo(ShipmentItemProxy::modelClass(), 'parent_id'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/ShipmentItemProxy.php b/packages/Webkul/Sales/src/Models/ShipmentItemProxy.php new file mode 100644 index 000000000..906cf7f08 --- /dev/null +++ b/packages/Webkul/Sales/src/Models/ShipmentItemProxy.php @@ -0,0 +1,10 @@ +loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->app->register(ModuleServiceProvider::class); } /** diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php new file mode 100644 index 000000000..f8fb0fa2a --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class InvoiceItemRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\InvoiceItem'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php new file mode 100644 index 000000000..173305183 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class InvoiceRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\Invoice'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php b/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php new file mode 100644 index 000000000..99d41f932 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/OrderAddressRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class OrderAddressRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\OrderAddress'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php new file mode 100644 index 000000000..d9cb23486 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class OrderItemRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\OrderItem'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php new file mode 100644 index 000000000..9c13d441d --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -0,0 +1,61 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class OrderRepository extends Repository +{ + /** + * OrderItemRepository object + * + * @var Object + */ + protected $orderItem; + + /** + * Create a new repository instance. + * + * @param Webkul\Sales\Repositories\OrderItemRepository $orderItem + * @return void + */ + public function __construct( + OrderItemRepository $orderItem, + App $app + ) + { + $this->orderItem = $orderItem; + + parent::__construct($app); + } + + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\Order'; + } + + /** + * @param array $data + * @return mixed + */ + public function create(array $data) + { + $order = $this->find(2); + + dd($order->customer); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php new file mode 100644 index 000000000..4bb2ccc56 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class ShipmentRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\Shipment'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/ShipmenttemRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmenttemRepository.php new file mode 100644 index 000000000..2e5428c65 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/ShipmenttemRepository.php @@ -0,0 +1,27 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class ShipmentItemRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return 'Webkul\Sales\Contracts\ShipmentItem'; + } +} \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php similarity index 100% rename from packages/Webkul/Cart/src/Http/Controllers/CartController.php rename to packages/Webkul/Shop/src/Http/Controllers/CartController.php diff --git a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php similarity index 94% rename from packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php rename to packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index d9271ad56..b7009390a 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -1,6 +1,6 @@ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CheckoutController extends Controller +class OnepageController extends Controller { /** * Contains route related configuration diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 65e12566d..d4f7abe6f 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -10,37 +10,45 @@ Route::group(['middleware' => ['web']], function () { 'view' => 'shop::products.index' ]); - Route::get('/checkout/onepage', 'Webkul\Cart\Http\Controllers\CheckoutController@index')->defaults('_config', [ + Route::get('/checkout/cart', 'Webkul\Shop\Http\Controllers\CartController@index')->defaults('_config', [ + 'view' => 'shop::checkout.cart.index' + ])->name('shop.checkout.cart.index'); + + Route::get('/checkout/onepage', 'Webkul\Shop\Http\Controllers\OnepageController@index')->defaults('_config', [ 'view' => 'shop::checkout.onepage' ])->name('shop.checkout.onepage.index'); - Route::post('/checkout/save-address', 'Webkul\Cart\Http\Controllers\CheckoutController@saveAddress')->name('shop.checkout.save-address'); + Route::post('/checkout/save-address', 'Webkul\Shop\Http\Controllers\CheckoutController@saveAddress')->name('shop.checkout.save-address'); - Route::post('/checkout/save-shipping', 'Webkul\Cart\Http\Controllers\CheckoutController@saveShipping')->name('shop.checkout.save-shipping'); + Route::post('/checkout/save-shipping', 'Webkul\Shop\Http\Controllers\CheckoutController@saveShipping')->name('shop.checkout.save-shipping'); - Route::post('/checkout/save-payment', 'Webkul\Cart\Http\Controllers\CheckoutController@savePayment')->name('shop.checkout.save-payment'); + Route::post('/checkout/save-payment', 'Webkul\Shop\Http\Controllers\CheckoutController@savePayment')->name('shop.checkout.save-payment'); + + Route::get('test', 'Webkul\Shop\Http\Controllers\CartController@test'); + + Route::get('mtest', 'Webkul\Shop\Http\Controllers\CartController@mergeTest'); //dummy - Route::get('test', 'Webkul\Cart\Http\Controllers\CartController@test'); + Route::get('test', 'Webkul\Shop\Http\Controllers\CartController@test'); Route::get('/products/{slug}', 'Webkul\Shop\Http\Controllers\ProductController@index')->defaults('_config', [ 'view' => 'shop::products.view' ])->name('shop.products.index'); // //Routes for product cart - Route::get('/checkout/cart', 'Webkul\Cart\Http\Controllers\CartController@index')->defaults('_config', [ - 'view' => 'shop::checkout.cart.index' - ])->name('shop.checkout.cart.index'); + // Route::get('/checkout/cart', 'Webkul\Shop\Http\Controllers\CartController@index')->defaults('_config', [ + // 'view' => 'shop::checkout.cart.index' + // ])->name('shop.checkout.cart.index'); - Route::post('product/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add'); + Route::post('product/cart/add/{id}', 'Webkul\Shop\Http\Controllers\CartController@add')->name('cart.add'); - Route::get('product/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove'); + Route::get('product/cart/remove/{id}', 'Webkul\Shop\Http\Controllers\CartController@remove')->name('cart.remove'); - Route::post('/checkout/cart', 'Webkul\Cart\Http\Controllers\CartController@updateBeforeCheckout')->defaults('_config',[ + Route::post('/checkout/cart', 'Webkul\Shop\Http\Controllers\CartController@updateBeforeCheckout')->defaults('_config',[ 'redirect' => 'shop.checkout.cart.index' ])->name('shop.checkout.cart.update'); - Route::get('/checkout/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->defaults('_config',[ + Route::get('/checkout/cart/remove/{id}', 'Webkul\Shop\Http\Controllers\CartController@remove')->defaults('_config',[ 'redirect' => 'shop.checkout.cart.index' ])->name('shop.checkout.cart.remove'); //Routes for product cart ends