diff --git a/composer.json b/composer.json index 48d0cd2dd..beb84f01f 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,8 @@ "Webkul\\Customer\\": "packages/Webkul/Customer/src", "Webkul\\Inventory\\": "packages/Webkul/Inventory/src", "Webkul\\Product\\": "packages/Webkul/Product/src", - "Webkul\\Theme\\": "packages/Webkul/Theme/src" + "Webkul\\Theme\\": "packages/Webkul/Theme/src", + "Webkul\\Cart\\": "packages/Webkul/Cart/src" } }, "autoload-dev": { diff --git a/config/app.php b/config/app.php index d34452c5f..d7d6cb7ae 100644 --- a/config/app.php +++ b/config/app.php @@ -172,6 +172,8 @@ return [ //Laravel Intervention Intervention\Image\ImageServiceProvider::class, + + //Repository Prettus\Repository\Providers\RepositoryServiceProvider::class, //Webkul packages @@ -187,7 +189,8 @@ return [ Webkul\Product\Providers\ProductServiceProvider::class, Webkul\Shop\Providers\ShopServiceProvider::class, Webkul\Customer\Providers\CustomerServiceProvider::class, - Webkul\Theme\Providers\ThemeServiceProvider::class + Webkul\Theme\Providers\ThemeServiceProvider::class, + Webkul\Cart\Providers\CartServiceProvider::class, ], /* diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index b00b203de..86d330715 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -66,7 +66,6 @@ class ProductDataGrid 'primaryKey' => 'prods.attribute_family_id', 'condition' => '=', 'secondaryKey' => 'attfam.id', - 'withAttributes' => false ], //for getting the attribute values. @@ -76,7 +75,12 @@ class ProductDataGrid 'primaryKey' => 'prods.id', 'condition' => '=', 'secondaryKey' => 'pav.product_id', - 'withAttributes' => true //use this boolean to select records as columns + 'withAttributes' => [ + 'condition' => [ + 'attribute_id' => 2, + 'select' => 'name', + ] + ] ], // for getting the inventory quantity of a product @@ -86,7 +90,6 @@ class ProductDataGrid 'primaryKey' => 'prods.id', 'condition' => '=', 'secondaryKey' => 'pi.product_id', - 'withAttributes' => false ], ], @@ -120,17 +123,9 @@ class ProductDataGrid 'name' => 'pi.qty', 'alias' => 'ProductQuantity', 'type' => 'string', - 'label' => 'Product Quatity', + 'label' => 'Product Quantity', 'sortable' => false, ], - [ - 'name' => 'pav.attribute_id', - 'alias' => 'AttributeID', - 'type' => 'string', - 'label' => 'Attribute ID', - 'sortable' => false, - - ], ], 'filterable' => [ diff --git a/packages/Webkul/Cart/composer.json b/packages/Webkul/Cart/composer.json new file mode 100644 index 000000000..ea46e9c47 --- /dev/null +++ b/packages/Webkul/Cart/composer.json @@ -0,0 +1,26 @@ +{ + "name": "webkul/laravel-cart", + "description": "Cart Package for customer.", + "license": "MIT", + "authors": [ + { + "name": "prashant-webkul", + "email": "prashant.singh852@webkul.com" + } + ], + "require": {}, + "autoload": { + "psr-4": { + "Webkul\\Cart\\": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "Webkul\\Cart\\Providers\\CartServiceProvider" + ], + "aliases": {} + } + }, + "minimum-stability": "dev" +} diff --git a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150444_create_cart_table.php b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150444_create_cart_table.php new file mode 100644 index 000000000..6a2195acc --- /dev/null +++ b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150444_create_cart_table.php @@ -0,0 +1,38 @@ +increments('id'); + $table->integer('customer_id')->unsigned()->nullable(); + $table->foreign('customer_id')->references('id')->on('customers'); + $table->string('session_id')->nullable(); + $table->integer('channel_id')->unsigned(); + $table->foreign('channel_id')->references('id')->on('channels'); + $table->string('coupon_code')->nullable(); + $table->boolean('is_gift')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cart'); + } +} diff --git a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php new file mode 100644 index 000000000..0d739e52e --- /dev/null +++ b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php @@ -0,0 +1,39 @@ +increments('id'); + $table->integer('product_id')->unsigned(); + $table->foreign('product_id')->references('id')->on('products'); + $table->integer('quantity')->unsigned()->default(1); + $table->integer('cart_id')->unsigned(); + $table->foreign('cart_id')->references('id')->on('cart'); + $table->integer('tax_category_id')->unsigned()->nullable(); + $table->foreign('tax_category_id')->references('id')->on('tax_categories'); + $table->string('coupon_code')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cart_items'); + } +} diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php new file mode 100644 index 000000000..21d5008e2 --- /dev/null +++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php @@ -0,0 +1,45 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class CartController extends Controller +{ + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + protected $_config; + + protected $cart; + + + public function __construct(CartRepository $cart) + { + $this->middleware(['customer', 'guest']); + + $this->_config = request('_config'); + + $this->cart = $cart; + } + + public function add() { + return "Adding Items to Cart"; + } +} \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Models/Cart.php b/packages/Webkul/Cart/src/Models/Cart.php new file mode 100644 index 000000000..c6d6e7ba4 --- /dev/null +++ b/packages/Webkul/Cart/src/Models/Cart.php @@ -0,0 +1,12 @@ +aliasMiddleware('customer', RedirectIfNotCustomer::class); + + $this->loadMigrationsFrom(__DIR__ . '/../Database/migrations'); + } + + /** + * Register services. + * + * @return void + */ + public function register() + { + // $this->app->bind('datagrid', 'Webkul\Ui\DataGrid\DataGrid'); + } +} diff --git a/packages/Webkul/Cart/src/Repositories/CartItemsRepository.php b/packages/Webkul/Cart/src/Repositories/CartItemsRepository.php new file mode 100644 index 000000000..72cd3c8d7 --- /dev/null +++ b/packages/Webkul/Cart/src/Repositories/CartItemsRepository.php @@ -0,0 +1,54 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class CartItemsRepository extends Repository +{ + /** + * Specify Model class name + * + * @return mixed + */ + + function model() + { + return 'Webkul\Cart\Models\CartItems'; + } + + /** + * @param array $data + * @return mixed + */ + + public function create(array $data) + { + $cartitems = $this->model->create($data); + + return $cartitems; + } + + /** + * @param array $data + * @param $id + * @param string $attribute + * @return mixed + */ + + public function update(array $data, $id, $attribute = "id") + { + $cartitems = $this->find($id); + + $cartitems->update($data); + + return $cartitems; + } +} \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Repositories/CartRepository.php b/packages/Webkul/Cart/src/Repositories/CartRepository.php new file mode 100644 index 000000000..27257051a --- /dev/null +++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php @@ -0,0 +1,54 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class CartRepository extends Repository +{ + /** + * Specify Model class name + * + * @return mixed + */ + + function model() + { + return 'Webkul\Cart\Models\Cart'; + } + + /** + * @param array $data + * @return mixed + */ + + public function create(array $data) + { + $cart = $this->model->create($data); + + return $cart; + } + + /** + * @param array $data + * @param $id + * @param string $attribute + * @return mixed + */ + + public function update(array $data, $id, $attribute = "id") + { + $cart = $this->find($id); + + $cart->update($data); + + return $cart; + } +} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php b/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php index e94aab612..5bc939083 100644 --- a/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php +++ b/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php @@ -160,22 +160,6 @@ class TaxCategoryController extends Controller } } - /** - * To perform the rollback - * if in anycase the taxMap - * records creates any problem. - * - * @return mixed - */ - public function performRollback($taxRuleId) { - - if($this->taxRule->delete($taxRuleId)) { - session()->flash('error', 'Cannot Create Tax Rule'); - - return redirect()->route('admin.taxrule.index'); - } - } - /** * Destroy a tax rule * diff --git a/packages/Webkul/Product/src/Http/Requests/ProductForm.php b/packages/Webkul/Product/src/Http/Requests/ProductForm.php index 812586f9d..b1b1ccb2c 100644 --- a/packages/Webkul/Product/src/Http/Requests/ProductForm.php +++ b/packages/Webkul/Product/src/Http/Requests/ProductForm.php @@ -85,10 +85,10 @@ class ProductForm extends FormRequest foreach ($attributes as $attribute) { if($attribute->code == 'sku') continue; - + if($product->type == 'configurable' && in_array($attribute->code, ['price', 'cost', 'special_price', 'special_price_from', 'special_price_to', 'width', 'height', 'depth', 'weight'])) continue; - + $validations = []; if($attribute->is_required) { array_push($validations, 'required'); diff --git a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php index e28c13eb4..f2028fbd1 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php @@ -1,5 +1,6 @@