diff --git a/.env.example b/.env.example index 76b6ac73c..bb471ec98 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,7 @@ DB_PORT=3306 DB_DATABASE= DB_USERNAME= DB_PASSWORD= +DB_PREFIX= BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/.env.testing b/.env.testing new file mode 100644 index 000000000..6b1104008 --- /dev/null +++ b/.env.testing @@ -0,0 +1,45 @@ +APP_NAME=Bagisto +APP_ENV=local +APP_VERSION=0.1.8 +APP_KEY=base64:NFtGjjFAqET6RlX3PVC/gFpzHb4jK1OxDc3cuU5Asz4= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=bagisto_test +DB_USERNAME=root +DB_PASSWORD=root + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=20 +QUEUE_DRIVER=sync + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME= +MAIL_PASSWORD= +MAIL_ENCRYPTION=tls + +SHOP_MAIL_FROM= +ADMIN_MAIL_TO= + +fixer_api_key= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/.github/ISSUE_TEMPLATE/3_Support_question.md b/.github/ISSUE_TEMPLATE/3_Support_question.md index a53ef6fa7..d6c5e5020 100644 --- a/.github/ISSUE_TEMPLATE/3_Support_question.md +++ b/.github/ISSUE_TEMPLATE/3_Support_question.md @@ -1,5 +1,5 @@ --- -name: "🧐 Support Question" +name: "❔ Support Question" about: 'This repository is only for reporting bugs or problems. If you need help, see: https://github.com/bagisto/bagisto#documentation' --- @@ -8,4 +8,4 @@ This repository is only for reporting bugs or issues. If you need support, pleas 1. Create support ticket on https://bagisto.uvdesk.com -Thanks! \ No newline at end of file +Thanks! diff --git a/.gitignore b/.gitignore index 1eea901cd..fa1eccb1e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ /public/js /public/vendor /public/themes -/storage/*.key /vendor /.idea /.vscode @@ -20,3 +19,6 @@ composer.lock yarn.lock package-lock.json yarn.lock +.php_cs.cache +storage/ +storage/*.key diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 000000000..18bdc7c08 --- /dev/null +++ b/codeception.yml @@ -0,0 +1,11 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed + diff --git a/composer.json b/composer.json index 7b0f8e7ea..e54a4ea36 100755 --- a/composer.json +++ b/composer.json @@ -2,9 +2,10 @@ "name": "bagisto/bagisto", "description": "Bagisto Laravel ECommerce", "keywords": [ - "framework", - "laravel" + "framework", + "laravel" ], + "license": "MIT", "type": "project", "require": { @@ -33,36 +34,40 @@ "prettus/l5-repository": "2.6.32", "tymon/jwt-auth": "1.0.0-rc.4" }, + "require-dev": { - "barryvdh/laravel-debugbar": "^3.1", - "filp/whoops": "^2.0", - "fzaninotto/faker": "^1.4", - "laravel/dusk": "^4.0", - "mockery/mockery": "^1.0", - "nunomaduro/collision": "^2.0", - "phpunit/phpunit": "^7.0" + "codeception/codeception": "3.1.*", + "barryvdh/laravel-debugbar": "^3.1", + "filp/whoops": "^2.0", + "fzaninotto/faker": "^1.4", + "laravel/dusk": "^4.0", + "mockery/mockery": "^1.0", + "nunomaduro/collision": "^2.0", + "phpunit/phpunit": "^7.0" }, + "replace": { - "bagisto/laravel-user": "v0.1.0", - "bagisto/laravel-admin": "v0.1.0", - "bagisto/laravel-ui": "v0.1.0", - "bagisto/laravel-core": "v0.1.0", - "bagisto/laravel-attribute": "v0.1.0", - "bagisto/laravel-checkout": "v0.1.0", - "bagisto/laravel-customer": "v0.1.0", - "bagisto/laravel-inventory": "v0.1.0", - "bagisto/laravel-category": "v0.1.0", - "bagisto/laravel-product": "v0.1.0", - "bagisto/laravel-shop": "v0.1.0", - "bagisto/laravel-theme": "v0.1.0", - "bagisto/laravel-shipping": "v0.1.0", - "bagisto/laravel-payment": "v0.1.0", - "bagisto/laravel-sales": "v0.1.0", - "bagisto/laravel-tax": "v0.1.0", - "bagisto/laravel-api": "v0.1.0", - "bagisto/laravel-paypal": "v0.1.0", - "bagisto/laravel-discount": "v0.1.0" + "bagisto/laravel-user": "v0.1.0", + "bagisto/laravel-admin": "v0.1.0", + "bagisto/laravel-ui": "v0.1.0", + "bagisto/laravel-core": "v0.1.0", + "bagisto/laravel-attribute": "v0.1.0", + "bagisto/laravel-checkout": "v0.1.0", + "bagisto/laravel-customer": "v0.1.0", + "bagisto/laravel-inventory": "v0.1.0", + "bagisto/laravel-category": "v0.1.0", + "bagisto/laravel-product": "v0.1.0", + "bagisto/laravel-shop": "v0.1.0", + "bagisto/laravel-theme": "v0.1.0", + "bagisto/laravel-shipping": "v0.1.0", + "bagisto/laravel-payment": "v0.1.0", + "bagisto/laravel-sales": "v0.1.0", + "bagisto/laravel-tax": "v0.1.0", + "bagisto/laravel-api": "v0.1.0", + "bagisto/laravel-paypal": "v0.1.0", + "bagisto/laravel-discount": "v0.1.0" }, + "autoload": { "classmap": [ "database/seeds", @@ -94,35 +99,48 @@ "Webkul\\CMS\\": "packages/Webkul/CMS/src" } }, + "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } + "psr-4": { + "Tests\\": "tests/" + } }, + "extra": { - "laravel": { - "dont-discover": [ - "barryvdh/laravel-debugbar", - "laravel/dusk" - ] - } + "laravel": { + "dont-discover": [ + "barryvdh/laravel-debugbar", + "laravel/dusk" + ] + } }, + "scripts": { - "post-root-package-install": [ - "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" - ], - "post-create-project-cmd": [ - "@php artisan key:generate" - ], - "post-autoload-dump": [ - "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover" - ] + "post-root-package-install": [ + "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + ], + + "post-create-project-cmd": [ + "@php artisan key:generate", + "Webkul\\Core\\Events\\ComposerEvents::postCreateProject" + ], + + "post-autoload-dump": [ + "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", + "@php artisan package:discover" + ], + "test": [ + "set -e", + "@php artisan migrate:fresh --env=testing", + "vendor/bin/codecept run unit", + "vendor/bin/codecept run functional" + ] }, "config": { - "preferred-install": "stable", - "sort-packages": true, - "optimize-autoloader": true + "preferred-install": "stable", + "sort-packages": true, + "optimize-autoloader": true }, - "minimum-stability": "dev" - } \ No newline at end of file + "minimum-stability": "dev", + "prefer-stable": true + } diff --git a/config/database.php b/config/database.php index 71280b1b1..e84936069 100755 --- a/config/database.php +++ b/config/database.php @@ -36,7 +36,7 @@ return [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', + 'prefix' => env('DB_PREFIX'), ], 'mysql' => [ @@ -49,7 +49,7 @@ return [ 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', + 'prefix' => env('DB_PREFIX'), 'strict' => false, 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', ], @@ -62,7 +62,7 @@ return [ 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', - 'prefix' => '', + 'prefix' => env('DB_PREFIX'), 'schema' => 'public', 'sslmode' => 'prefer', ], diff --git a/config/mail.php b/config/mail.php index 6b4631bf2..677ed43cd 100755 --- a/config/mail.php +++ b/config/mail.php @@ -60,6 +60,20 @@ return [ 'name' => env('MAIL_FROM_NAME') ], + /* + |-------------------------------------------------------------------------- + | Global "Admin" Address + |-------------------------------------------------------------------------- + | + | General admin related admins, such as order notifications. + | + */ + + 'admin' => [ + 'address' => env('ADMIN_MAIL_TO'), + 'name' => env('ADMIN_MAIL_NAME', 'Admin') + ], + /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol diff --git a/packages/Webkul/API/Http/Resources/Catalog/Product.php b/packages/Webkul/API/Http/Resources/Catalog/Product.php index 711ed1c42..c4a1ec895 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Product.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Product.php @@ -3,6 +3,7 @@ namespace Webkul\API\Http\Resources\Catalog; use Illuminate\Http\Resources\Json\JsonResource; +use Webkul\Product\Helpers\ProductType; class Product extends JsonResource { @@ -44,7 +45,7 @@ class Product extends JsonResource 'base_image' => $this->productImageHelper->getProductBaseImage($product), 'variants' => Self::collection($this->variants), 'in_stock' => $product->haveSufficientQuantity(1), - $this->mergeWhen($product->type == 'configurable', [ + $this->mergeWhen($product->getTypeInstance()->isComposite(), [ 'super_attributes' => Attribute::collection($product->super_attributes), ]), 'special_price' => $this->when( diff --git a/packages/Webkul/Admin/src/Config/menu.php b/packages/Webkul/Admin/src/Config/menu.php index ce1da1d85..a1420eb85 100755 --- a/packages/Webkul/Admin/src/Config/menu.php +++ b/packages/Webkul/Admin/src/Config/menu.php @@ -182,6 +182,12 @@ return [ 'sort' => 2, 'icon-class' => '' ], [ + 'key' => 'settings.development', + 'name' => 'admin::app.settings.development.title', + 'route' => 'admin.development.index', + 'sort' => 8, + 'icon-class' => '' + ],[ 'key' => 'promotions', 'name' => 'admin::app.layouts.promotions', 'route' => 'admin.catalog-rules.index', diff --git a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index 4c2de244c..ac7bbc749 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -28,19 +28,19 @@ class AddressDataGrid extends DataGrid * @var object */ protected $customer; - + /** * Create a new controller instance. * * @param Webkul\Customer\Repositories\CustomerRepository $customer * @return void */ - public function __construct( + public function __construct( Customer $customer ) { parent::__construct(); - + $this->customer = $customer; } @@ -52,7 +52,7 @@ class AddressDataGrid extends DataGrid $queryBuilder = DB::table('customer_addresses as ca') ->leftJoin('countries', 'ca.country', '=', 'countries.code') ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') - ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw('countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') + ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw(''.DB::getTablePrefix().'countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') ->where('c.id', $customer->id); $queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) { @@ -62,13 +62,13 @@ class AddressDataGrid extends DataGrid $queryBuilder ->groupBy('ca.id') - ->addSelect(DB::raw('country_states.default_name as state_name')); + ->addSelect(DB::raw(''.DB::getTablePrefix().'country_states.default_name as state_name')); $this->addFilter('address_id', 'ca.id'); $this->addFilter('address1', 'ca.address1'); $this->addFilter('city', 'ca.city'); - $this->addFilter('state_name', DB::raw('country_states.default_name')); - $this->addFilter('country_name', DB::raw('countries.name')); + $this->addFilter('state_name', DB::raw(''.DB::getTablePrefix().'country_states.default_name')); + $this->addFilter('country_name', DB::raw(''.DB::getTablePrefix().'countries.name')); $this->addFilter('postcode', 'ca.postcode'); $this->addFilter('default_address', 'ca.default_address'); diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 7073e047c..98f7152a7 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -21,7 +21,7 @@ class CategoryDataGrid extends DataGrid { $queryBuilder = DB::table('categories as cat') ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', - DB::raw('COUNT(DISTINCT pc.product_id) as count')) + DB::raw('COUNT(DISTINCT '.DB::getTablePrefix().'pc.product_id) as count')) ->leftJoin('category_translations as ct', function($leftJoin) { $leftJoin->on('cat.id', '=', 'ct.category_id') ->where('ct.locale', app()->getLocale()); diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 6952abca6..beba7a4b9 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -25,10 +25,10 @@ class CustomerDataGrid extends DataGrid $queryBuilder = DB::table('customers') ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') - ->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as full_name')); + ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'customers.first_name, " ", '.DB::getTablePrefix().'customers.last_name) as full_name')); $this->addFilter('customer_id', 'customers.id'); - $this->addFilter('full_name', DB::raw('CONCAT(customers.first_name, " ", customers.last_name)')); + $this->addFilter('full_name', DB::raw('CONCAT('.DB::getTablePrefix().'customers.first_name, " ", '.DB::getTablePrefix().'customers.last_name)')); $this->addFilter('phone', 'customers.phone'); $this->addFilter('gender', 'customers.gender'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index aa2d91b68..7b8049f84 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,11 +29,11 @@ class OrderDataGrid extends DataGrid ->where('order_address_billing.address_type', 'billing'); }) ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')) - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name) as shipped_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name)')); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('created_at', 'orders.created_at'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 2e4b09a37..2c425cb70 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -26,9 +26,9 @@ class OrderRefundDataGrid extends DataGrid $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') ->where('order_address_billing.address_type', 'billing'); }) - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')); + ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name) as billed_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT('.DB::getTablePrefix().'order_address_billing.first_name, " ", '.DB::getTablePrefix().'order_address_billing.last_name)')); $this->addFilter('id', 'refunds.id'); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('state', 'refunds.state'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 9c94dbf69..c6a30567f 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -27,7 +27,7 @@ class OrderShipmentsDataGrid extends DataGrid ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT('.DB::getTablePrefix().'order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name) as shipped_to')); $this->addFilter('shipment_id', 'shipments.id'); $this->addFilter('shipment_order_id', 'ors.increment_id'); @@ -35,7 +35,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addFilter('inventory_source_name', 'is.name'); $this->addFilter('order_date', 'ors.created_at'); $this->addFilter('shipment_created_at', 'shipments.created_at'); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('shipped_to', DB::raw(''.DB::getTablePrefix().'CONCAT(order_address_shipping.first_name, " ", '.DB::getTablePrefix().'order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index bac760717..d254106fb 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -17,7 +17,7 @@ class ProductDataGrid extends DataGrid protected $index = 'product_id'; - protected $itemsPerPage = 20; + protected $itemsPerPage = 10; public function prepareQueryBuilder() { @@ -25,7 +25,7 @@ class ProductDataGrid extends DataGrid ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') - ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(product_inventories.qty) as quantity')) + ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM('.DB::getTablePrefix().'product_inventories.qty) as quantity')) ->where('channel', core()->getCurrentChannelCode()) ->where('locale', app()->getLocale()) ->groupBy('product_flat.product_id'); @@ -152,7 +152,7 @@ class ProductDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ 'type' => 'delete', - 'label' => 'Delete', + 'label' => 'Delete', 'action' => route('admin.catalog.products.massdelete'), 'method' => 'DELETE' ]); diff --git a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php index aaaec0503..30ab97908 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php @@ -120,6 +120,10 @@ class ConfigurationController extends Controller { Event::fire('core.configuration.save.before'); + $this->validate(request(), [ + 'general.design.admin_logo.logo_image' => 'mimes:jpeg,bmp,png,jpg' + ]); + $this->coreConfigRepository->create(request()->all()); Event::fire('core.configuration.save.after'); diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index b9d3d47ba..c77a66a73 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -186,7 +186,7 @@ class DashboardController extends Controller ->where('order_items.created_at', '>=', $this->startDate) ->where('order_items.created_at', '<=', $this->endDate) ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) - ->addSelect(DB::raw('COUNT(products.id) as total_products')) + ->addSelect(DB::raw('COUNT('.DB::getTablePrefix().'products.id) as total_products')) ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') ->groupBy('categories.id') ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') diff --git a/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php new file mode 100755 index 000000000..89dbecf9a --- /dev/null +++ b/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php @@ -0,0 +1,24 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class DashboardController extends Controller +{ + /** + * Display a listing of the resource. + * + * @return \Illuminate\View\View + */ + public function index() + { + return view('admin::settings.development.dashboard'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index da28c17f3..6da6f2068 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -278,7 +278,7 @@ Route::group(['middleware' => ['web']], function () { Route::post('/products/upload-file/{id}', 'Webkul\Product\Http\Controllers\ProductController@uploadLink')->name('admin.catalog.products.upload_link'); Route::post('/products/upload-sample/{id}', 'Webkul\Product\Http\Controllers\ProductController@uploadSample')->name('admin.catalog.products.upload_sample'); - + //product delete Route::post('/products/delete/{id}', 'Webkul\Product\Http\Controllers\ProductController@destroy')->name('admin.catalog.products.delete'); @@ -756,6 +756,12 @@ Route::group(['middleware' => ['web']], function () { // 'redirect' => 'admin.cms.index' // ])->name('admin.cms.delete'); }); + + // Development settings + Route::prefix('development')->group(function () { + Route::get('/', 'Webkul\Admin\Http\Controllers\Development\DashboardController@index') + ->name('admin.development.index'); + }); }); }); -}); \ No newline at end of file +}); diff --git a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php index fa9d5d199..b31a4ab1c 100644 --- a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php @@ -42,7 +42,7 @@ class NewAdminNotification extends Mailable */ public function build() { - return $this->to(env('ADMIN_MAIL_TO')) + return $this->to(config('mail.admin.address')) ->subject(trans('shop::app.mail.order.subject')) ->view('shop::emails.sales.new-admin-order'); } diff --git a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php index a816d0d05..c5f833aea 100755 --- a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php @@ -45,7 +45,7 @@ class NewInvoiceNotification extends Mailable $order = $this->invoice->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-invoice'); } diff --git a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php index c53782ac7..2298d1463 100755 --- a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php @@ -42,7 +42,7 @@ class NewOrderNotification extends Mailable public function build() { return $this->to($this->order->customer_email, $this->order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.order.subject')) ->view('shop::emails.sales.new-order'); } diff --git a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php index e682d10b0..8c4d9602f 100644 --- a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php @@ -45,7 +45,7 @@ class NewRefundNotification extends Mailable $order = $this->refund->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-refund'); } diff --git a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php index 1a90aa5f9..9f1140281 100755 --- a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php @@ -45,7 +45,7 @@ class NewShipmentNotification extends Mailable $order = $this->shipment->order; return $this->to($order->customer_email, $order->customer_full_name) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) ->view('shop::emails.sales.new-shipment'); } diff --git a/packages/Webkul/Admin/src/Resources/lang/ar/app.php b/packages/Webkul/Admin/src/Resources/lang/ar/app.php index 486e1d0f8..12f184e84 100644 --- a/packages/Webkul/Admin/src/Resources/lang/ar/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/ar/app.php @@ -726,6 +726,9 @@ return [ 'update-error' => 'خطأ! معدل الضرائب لا يمكن تحديثه', 'delete' => 'معدل الضريبة محذوف بنجاح', 'atleast-one' => 'لا يستطيع حذف الأخير ضريبة معدل' + ], + 'development' => [ + 'title' => 'تطوير', ] ], @@ -910,6 +913,7 @@ return [ 'order-number-length' => 'Order Number Length', 'order-number-suffix' => 'Order Number Suffix', 'default' => 'Default', + 'sandbox' => 'Sandbox' ] ] ]; \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 923824e7c..0c50fc0ab 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -845,6 +845,9 @@ return [ 'update-error' => 'Error! Tax Rate Cannot Be Updated', 'delete' => 'Tax Rate Deleted Successfully', 'atleast-one' => 'Cannot Delete Last Tax Rate' + ], + 'development' => [ + 'title' => 'Development', ] ], @@ -1253,6 +1256,7 @@ return [ 'order-number-length' => 'Order Number Length', 'order-number-suffix' => 'Order Number Suffix', 'default' => 'Default', + 'sandbox' => 'Sandbox' ] ] ]; diff --git a/packages/Webkul/Admin/src/Resources/lang/fa/app.php b/packages/Webkul/Admin/src/Resources/lang/fa/app.php index 47ea90265..ad5d4ca54 100644 --- a/packages/Webkul/Admin/src/Resources/lang/fa/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/fa/app.php @@ -761,6 +761,9 @@ return [ 'update-error' => 'خطا! نرخ مالیات نمی تواند به روز شود', 'delete' => 'نرخ مالیات با موفقیت حذف شد', 'atleast-one' => 'آخرین نرخ مالیات نمی تواند حذف شود' + ], + 'development' => [ + 'title' => 'توسعه', ] ], @@ -1048,7 +1051,8 @@ return [ 'logo-image' => 'تصویر لوگو', 'credit-max' => 'اعتبار مشتری حداکثر', 'credit-max-value' => 'حداکثر میزان اعتبار', - 'use-credit-max' => 'استفاده از حداکثر اعتبار' + 'use-credit-max' => 'استفاده از حداکثر اعتبار', + 'sandbox' => 'Sandbox' ] ] ]; diff --git a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php index 36295dd3f..3aeb94034 100755 --- a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php @@ -584,7 +584,6 @@ return [ 'title' => 'Idiomas', 'add-title' => 'Add Idioma', 'edit-title' => 'Editar Idioma', - 'add-title' => 'Add Idioma', 'save-btn-title' => 'Salvar Idioma', 'general' => 'Geral', 'code' => 'Código', @@ -753,6 +752,9 @@ return [ 'update-error' => 'Erro! Taxas de Impostos Não Poderam ser Atualizadas', 'delete' => 'Taxas de Impostos Excluídas com Sucesso', 'atleast-one' => 'Não é Possível Excluir a Última Taxa de Impostos' + ], + 'development' => [ + 'title' => 'Desenvolvimento', ] ], 'customers' => [ @@ -1033,6 +1035,7 @@ return [ 'order-number-prefix' => 'Order Number Prefix', 'order-number-length' => 'Order Number Length', 'order-number-suffix' => 'Order Number Suffix', + 'sandbox' => 'Sandbox' ] ] ]; \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/attributes/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/attributes/edit.blade.php index 28c9716ba..5b494956e 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/attributes/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/attributes/edit.blade.php @@ -77,7 +77,7 @@ - @@ -461,4 +461,4 @@ } }); -@endpush \ No newline at end of file +@endpush diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php index c3ff363e0..7308fd5c1 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php @@ -64,7 +64,7 @@ @if ($familyId) - + @endif @{{ errors.first('type') }} diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php index 2b4d5a239..e76ff2035 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php @@ -17,7 +17,8 @@

- + {{ __('admin::app.catalog.products.edit-title') }}

@@ -26,7 +27,8 @@ @foreach (core()->getAllLocales() as $localeModel) - @@ -66,31 +69,37 @@ {!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.' . $attributeGroup->name . '.before', ['product' => $product]) !!} - +
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.' . $attributeGroup->name . '.controls.before', ['product' => $product]) !!} @foreach ($customAttributes as $attribute) is_required) - array_push($validations, 'required'); + if ($attribute->is_required) { + array_push($validations, 'required'); + } - if ($attribute->type == 'price') - array_push($validations, 'decimal'); + if ($attribute->type == 'price') { + array_push($validations, 'decimal'); + } - array_push($validations, $attribute->validation); + array_push($validations, $attribute->validation); - $validations = implode('|', array_filter($validations)); + $validations = implode('|', array_filter($validations)); ?> @if (view()->exists($typeView = 'admin::catalog.products.field-types.' . $attribute->type)) -
type == 'multiselect') :class="[errors.has('{{ $attribute->code }}[]') ? 'has-error' : '']" @else :class="[errors.has('{{ $attribute->code }}') ? 'has-error' : '']" @endif> +
type == 'multiselect') :class="[errors.has('{{ $attribute->code }}[]') ? 'has-error' : '']" + @else :class="[errors.has('{{ $attribute->code }}') ? 'has-error' : '']" @endif> -
@@ -173,4 +194,4 @@ }); }); -@endpush \ No newline at end of file +@endpush diff --git a/packages/Webkul/Admin/src/Resources/views/dashboard/index.blade.php b/packages/Webkul/Admin/src/Resources/views/dashboard/index.blade.php index ed5ff69bb..8de719884 100755 --- a/packages/Webkul/Admin/src/Resources/views/dashboard/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/dashboard/index.blade.php @@ -274,7 +274,7 @@ {{ __('admin::app.dashboard.order-count', ['count' => $item->total_orders]) }}  .  {{ __('admin::app.dashboard.revenue', [ - 'total' => core()->formatBasePrice($item->total_base_grand_total_invoiced) + 'total' => core()->formatBasePrice($item->total_base_grand_total) ]) }}
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index 534bc1bef..c635af49e 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -48,6 +48,8 @@
+ {!! view_render_event('sales.order.tabs.before', ['order' => $order]) !!} +
@@ -506,8 +508,10 @@
+ + {!! view_render_event('sales.order.tabs.after', ['order' => $order]) !!}
-@stop \ No newline at end of file +@stop diff --git a/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php index 8a273df8b..e0e0ac3d1 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php @@ -241,14 +241,14 @@ @foreach ($order->items as $item) - {{ $item->type == 'configurable' ? $item->child->sku : $item->sku }} + {{ Webkul\Product\Helpers\ProductType::hasVariants($item->type) ? $item->child->sku : $item->sku }} {{ $item->name }} @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -417,7 +417,7 @@ if (! response.data) { window.flashMessages = [{ 'type': 'alert-error', - 'message': "{{ __('admin::app.sales.refunds.invalid-qty') }}" + 'message': "{{ __('admin::app.sales.refunds.invalid-qty') }}" }]; this_this.$root.addFlashMessages() diff --git a/packages/Webkul/Admin/src/Resources/views/settings/development/dashboard.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/development/dashboard.blade.php new file mode 100755 index 000000000..1eaf61ad0 --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/settings/development/dashboard.blade.php @@ -0,0 +1,19 @@ +@extends('admin::layouts.content') + +@section('page_title') + {{ __('admin::app.settings.development.title') }} +@stop + +@section('content') +
+ + +
+ +
+
+@stop \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/settings/sliders/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/sliders/edit.blade.php index cd24bd2a1..af5e28126 100755 --- a/packages/Webkul/Admin/src/Resources/views/settings/sliders/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/sliders/edit.blade.php @@ -52,7 +52,7 @@
- path) }}"' > + @foreach ($errors->get('image.*') as $key => $message) diff --git a/packages/Webkul/Attribute/src/resources/manifest.php b/packages/Webkul/Attribute/src/resources/manifest.php new file mode 100644 index 000000000..5949213de --- /dev/null +++ b/packages/Webkul/Attribute/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Attributes', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php index 8af28df46..814f7ae00 100644 --- a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php +++ b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php @@ -40,7 +40,9 @@ use Webkul\Core\Repositories\LocaleRepository as Locale; /** * Pass the class instance through admin middleware */ - $this->middleware('auth:admin'); + // $this->middleware('auth:admin'); + + $this->middleware('admin'); /** * Channel repository instance diff --git a/packages/Webkul/CMS/src/resources/manifest.php b/packages/Webkul/CMS/src/resources/manifest.php new file mode 100644 index 000000000..93bd520c2 --- /dev/null +++ b/packages/Webkul/CMS/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Cms', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php b/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php new file mode 100644 index 000000000..941601997 --- /dev/null +++ b/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php @@ -0,0 +1,19 @@ +define(Category::class, function (Faker $faker, array $attributes) { + + return [ + 'status' => 1, + 'position' => $faker->randomDigit, + 'parent_id' => 1, + ]; +}); + +$factory->state(Category::class, 'inactive', [ + 'status' => 0, +]); diff --git a/packages/Webkul/Category/src/Models/Category.php b/packages/Webkul/Category/src/Models/Category.php index 8a38f7c02..b40ff1a77 100755 --- a/packages/Webkul/Category/src/Models/Category.php +++ b/packages/Webkul/Category/src/Models/Category.php @@ -8,6 +8,13 @@ use Illuminate\Support\Facades\Storage; use Webkul\Category\Contracts\Category as CategoryContract; use Webkul\Attribute\Models\AttributeProxy; +/** + * Class Category + * + * @package Webkul\Category\Models + * + * @property-read string $url_path maintained by database triggers + */ class Category extends TranslatableModel implements CategoryContract { use NodeTrait; diff --git a/packages/Webkul/Category/src/Models/CategoryTranslation.php b/packages/Webkul/Category/src/Models/CategoryTranslation.php index 6916e3146..fc6318486 100755 --- a/packages/Webkul/Category/src/Models/CategoryTranslation.php +++ b/packages/Webkul/Category/src/Models/CategoryTranslation.php @@ -5,6 +5,13 @@ namespace Webkul\Category\Models; use Illuminate\Database\Eloquent\Model; use Webkul\Category\Contracts\CategoryTranslation as CategoryTranslationContract; +/** + * Class CategoryTranslation + * + * @package Webkul\Category\Models + * + * @property-read string $url_path maintained by database triggers + */ class CategoryTranslation extends Model implements CategoryTranslationContract { public $timestamps = false; diff --git a/packages/Webkul/Category/src/Observers/CategoryObserver.php b/packages/Webkul/Category/src/Observers/CategoryObserver.php index 892749698..6603dd624 100644 --- a/packages/Webkul/Category/src/Observers/CategoryObserver.php +++ b/packages/Webkul/Category/src/Observers/CategoryObserver.php @@ -3,6 +3,8 @@ namespace Webkul\Category\Observers; use Illuminate\Support\Facades\Storage; +use Webkul\Category\Models\Category; +use Carbon\Carbon; class CategoryObserver { @@ -16,4 +18,16 @@ class CategoryObserver { Storage::deleteDirectory('category/' . $category->id); } + + /** + * Handle the Category "saved" event. + * + * @param Category $category + */ + public function saved($category) + { + foreach ($category->children as $child) { + $child->touch(); + } + } } \ No newline at end of file diff --git a/packages/Webkul/Category/src/Providers/CategoryServiceProvider.php b/packages/Webkul/Category/src/Providers/CategoryServiceProvider.php index a395001b1..0345ddf5c 100755 --- a/packages/Webkul/Category/src/Providers/CategoryServiceProvider.php +++ b/packages/Webkul/Category/src/Providers/CategoryServiceProvider.php @@ -2,6 +2,7 @@ namespace Webkul\Category\Providers; +use Illuminate\Database\Eloquent\Factory as EloquentFactory; use Illuminate\Support\ServiceProvider; use Webkul\Category\Models\CategoryProxy; use Webkul\Category\Observers\CategoryObserver; @@ -18,6 +19,8 @@ class CategoryServiceProvider extends ServiceProvider $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); CategoryProxy::observe(CategoryObserver::class); + + $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); } /** @@ -29,4 +32,15 @@ class CategoryServiceProvider extends ServiceProvider { } + + /** + * Register factories. + * + * @param string $path + * @return void + */ + protected function registerEloquentFactoriesFrom($path): void + { + $this->app->make(EloquentFactory::class)->load($path); + } } \ No newline at end of file diff --git a/packages/Webkul/Category/src/Repositories/CategoryRepository.php b/packages/Webkul/Category/src/Repositories/CategoryRepository.php index e6380d55f..004f5b15a 100755 --- a/packages/Webkul/Category/src/Repositories/CategoryRepository.php +++ b/packages/Webkul/Category/src/Repositories/CategoryRepository.php @@ -151,6 +151,16 @@ class CategoryRepository extends Repository ); } + /** + * @param string $urlPath + * + * @return mixed + */ + public function findByPath(string $urlPath) + { + return $this->model->whereTranslation('url_path', $urlPath)->first(); + } + /** * @param array $data * @param $id diff --git a/packages/Webkul/Category/src/resources/manifest.php b/packages/Webkul/Category/src/resources/manifest.php new file mode 100644 index 000000000..b3f21240d --- /dev/null +++ b/packages/Webkul/Category/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Categories', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Checkout/src/resources/manifest.php b/packages/Webkul/Checkout/src/resources/manifest.php new file mode 100644 index 000000000..c75b737bd --- /dev/null +++ b/packages/Webkul/Checkout/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Checkout', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 9bfc791a3..963af1b00 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -211,7 +211,13 @@ class Core if ($locale) return $locale; - return $locale = $this->localeRepository->findOneByField('code', app()->getLocale()); + $locale = $this->localeRepository->findOneByField('code', app()->getLocale()); + + if(!$locale) { + $locale = $this->localeRepository->findOneByField('code', config('app.fallback_locale')); + } + + return $locale; } /** diff --git a/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php b/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php new file mode 100644 index 000000000..0ab390c2f --- /dev/null +++ b/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php @@ -0,0 +1,19 @@ +define(Locale::class, function (Faker $faker, array $attributes) { + + return [ + 'code' => $faker->languageCode, + 'name' => $faker->country, + 'direction' => 'ltr', + ]; +}); + +$factory->state(Category::class, 'rtl', [ + 'direction' => 'rtl', +]); diff --git a/packages/Webkul/Core/src/Events/ComposerEvents.php b/packages/Webkul/Core/src/Events/ComposerEvents.php new file mode 100644 index 000000000..0ee700715 --- /dev/null +++ b/packages/Webkul/Core/src/Events/ComposerEvents.php @@ -0,0 +1,15 @@ +writeln(file_get_contents(__DIR__ . '/../Templates/on-boarding.php')); + } +} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php index da5a3859a..949e565b4 100755 --- a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php +++ b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php @@ -2,6 +2,7 @@ namespace Webkul\Core\Providers; +use Illuminate\Database\Eloquent\Factory as EloquentFactory; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\AliasLoader; @@ -36,6 +37,8 @@ class CoreServiceProvider extends ServiceProvider ]); SliderProxy::observe(SliderObserver::class); + + $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); } /** @@ -61,4 +64,15 @@ class CoreServiceProvider extends ServiceProvider return app()->make(Core::class); }); } + + /** + * Register factories. + * + * @param string $path + * @return void + */ + protected function registerEloquentFactoriesFrom($path): void + { + $this->app->make(EloquentFactory::class)->load($path); + } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Templates/on-boarding.php b/packages/Webkul/Core/src/Templates/on-boarding.php new file mode 100644 index 000000000..21ff4eaea --- /dev/null +++ b/packages/Webkul/Core/src/Templates/on-boarding.php @@ -0,0 +1,14 @@ + + ____ _ _ +| __ ) __ _ __ _(_)___| |_ ___ +| _ \ / _` |/ _` | / __| __/ _ \ +| |_) | (_| | (_| | \__ \ || (_) | +|____/ \__,_|\__, |_|___/\__\___/ + |___/ + + + +Welcome to the Bagisto project! Bagisto Community is an open-source e-commerce ecosystem +which is built on top of Laravel and Vue.js. + +Made with 💖 by the Bagisto Team. Happy helping :) diff --git a/packages/Webkul/Core/src/resources/manifest.php b/packages/Webkul/Core/src/resources/manifest.php new file mode 100644 index 000000000..fae55b951 --- /dev/null +++ b/packages/Webkul/Core/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Core', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php index b29d8ead2..e1e50d0b4 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php @@ -93,8 +93,9 @@ class CustomerController extends Controller 'gender' => 'required', 'date_of_birth' => 'date|before:today', 'email' => 'email|unique:customers,email,'.$id, + 'password' => 'confirmed|min:6|required_with:oldpassword', 'oldpassword' => 'required_with:password', - 'password' => 'confirmed|min:6' + 'password_confirmation' => 'required_with:password', ]); $data = collect(request()->input())->except('_token')->toArray(); @@ -139,27 +140,26 @@ class CustomerController extends Controller $customerRepository = $this->customerRepository->findorFail($id); - $orders = $customerRepository->all_orders->whereIn('status', ['pending', 'processing'])->first(); - - if ( $orders ) { - session()->flash('error', trans('admin::app.response.order-pending')); - - return redirect()->route($this->_config['redirect']); - } - try { - if ( Hash::check($data['password'], $customerRepository->password) ) { + if (Hash::check($data['password'], $customerRepository->password)) { + $orders = $customerRepository->all_orders->whereIn('status', ['pending', 'processing'])->first(); - $this->customerRepository->delete($id); + if ($orders) { + session()->flash('error', trans('admin::app.response.order-pending')); - session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer'])); + return redirect()->route($this->_config['redirect']); + } else { + $this->customerRepository->delete($id); - return redirect()->route('customer.session.index'); + session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer'])); + + return redirect()->route('customer.session.index'); + } } else { session()->flash('error', trans('shop::app.customer.account.address.delete.wrong-password')); - } - return redirect()->route('customer.session.index'); + return redirect()->back(); + } } catch(\Exception $e) { session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer'])); diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index 24790355f..5fc59c6d9 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -59,15 +59,12 @@ class WishlistController extends Controller /** * Displays the listing resources if the customer having items in wishlist. - * + * * @return \Illuminate\View\View */ public function index() { - $wishlistItems = $this->wishlistRepository->findWhere([ - 'channel_id' => core()->getCurrentChannel()->id, - 'customer_id' => auth()->guard('customer')->user()->id] - ); + $wishlistItems = $this->wishlistRepository->getCustomerWhishlist(); return view($this->_config['view'])->with('items', $wishlistItems); } @@ -166,14 +163,14 @@ class WishlistController extends Controller } else { session()->flash('info', trans('shop::app.wishlist.option-missing')); - return redirect()->route('shop.products.index', $wishlistItem->product->url_key); + return redirect()->route('shop.productOrCategory.index', $wishlistItem->product->url_key); } return redirect()->back(); } catch (\Exception $e) { session()->flash('warning', $e->getMessage()); - return redirect()->route('shop.products.index', ['slug' => $wishlistItem->product->url_key]); + return redirect()->route('shop.productOrCategory.index', ['slug' => $wishlistItem->product->url_key]); } } diff --git a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php index ffd045e90..a93424b53 100644 --- a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php +++ b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php @@ -31,7 +31,7 @@ class RegistrationEmail extends Mailable public function build() { return $this->to($this->data['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.registration.customer-registration')) ->view('shop::emails.customer.registration')->with('data', $this->data); } diff --git a/packages/Webkul/Customer/src/Mail/VerificationEmail.php b/packages/Webkul/Customer/src/Mail/VerificationEmail.php index 9091d7afc..6f987bd3b 100755 --- a/packages/Webkul/Customer/src/Mail/VerificationEmail.php +++ b/packages/Webkul/Customer/src/Mail/VerificationEmail.php @@ -31,7 +31,7 @@ class VerificationEmail extends Mailable public function build() { return $this->to($this->verificationData['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.verification.subject')) ->view('shop::emails.customer.verification-email')->with('data', ['email' => $this->verificationData['email'], 'token' => $this->verificationData['token']]); } diff --git a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php index 1f8b39858..ddb4e1956 100755 --- a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php +++ b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php @@ -21,7 +21,7 @@ class CustomerResetPassword extends ResetPassword } return (new MailMessage) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(__('shop::app.mail.forget-password.subject') ) ->view('shop::emails.customer.forget-password', [ 'user_name' => $notifiable->name, diff --git a/packages/Webkul/Customer/src/Repositories/WishlistRepository.php b/packages/Webkul/Customer/src/Repositories/WishlistRepository.php index cd25ef3ed..a491d3828 100755 --- a/packages/Webkul/Customer/src/Repositories/WishlistRepository.php +++ b/packages/Webkul/Customer/src/Repositories/WishlistRepository.php @@ -62,8 +62,7 @@ class WishlistRepository extends Repository return $this->model->find($id)->item_wishlist; } - - /** + /** * get customer wishlist Items. * * @return mixed diff --git a/packages/Webkul/Customer/src/resources/manifest.php b/packages/Webkul/Customer/src/resources/manifest.php new file mode 100644 index 000000000..c732276af --- /dev/null +++ b/packages/Webkul/Customer/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Customer', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Inventory/src/resources/manifest.php b/packages/Webkul/Inventory/src/resources/manifest.php new file mode 100644 index 000000000..dbad5913f --- /dev/null +++ b/packages/Webkul/Inventory/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Inventory', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Payment/src/Config/system.php b/packages/Webkul/Payment/src/Config/system.php index 3e1b22195..6fc22a4a2 100755 --- a/packages/Webkul/Payment/src/Config/system.php +++ b/packages/Webkul/Payment/src/Config/system.php @@ -159,7 +159,23 @@ return [ 'validation' => 'required', 'channel_based' => false, 'locale_based' => true - ], [ + ], [ + 'name' => 'sandbox', + 'title' => 'admin::app.admin.system.sandbox', + 'type' => 'select', + 'options' => [ + [ + 'title' => 'Active', + 'value' => true + ], [ + 'title' => 'Inactive', + 'value' => false + ] + ], + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true + ], [ 'name' => 'sort', 'title' => 'admin::app.admin.system.sort_order', 'type' => 'select', diff --git a/packages/Webkul/Product/src/Helpers/ProductType.php b/packages/Webkul/Product/src/Helpers/ProductType.php new file mode 100644 index 000000000..103b1ed58 --- /dev/null +++ b/packages/Webkul/Product/src/Helpers/ProductType.php @@ -0,0 +1,39 @@ +hasVariants(); + } + + /** + * Get all ProductTypes that are allowed to have variants + * + * @return array of product_types->keys + */ + public static function getAllTypesHavingVariants(): array + { + foreach (config('product_types') as $type) { + if (self::hasVariants($type['key'])) { + array_push($havingVariants, $type['key']); + } + } + + return $havingVariants; + } +} \ No newline at end of file diff --git a/packages/Webkul/Product/src/Helpers/Review.php b/packages/Webkul/Product/src/Helpers/Review.php index ff3b5394d..6d109f729 100755 --- a/packages/Webkul/Product/src/Helpers/Review.php +++ b/packages/Webkul/Product/src/Helpers/Review.php @@ -40,7 +40,7 @@ class Review extends AbstractProduct if(array_key_exists($product->id, $avgRating)) return $avgRating[$product->id]; - return $avgRating[$product->id] = number_format(round($product->reviews()->where('status', 'approved')->average('rating'), 2), 1); + return $avgRating[$product->id] = number_format(round($product->reviews()->where('status', 'approved')->avg('rating'), 2), 1); } /** diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 0a4d0da0c..9134991d4 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -4,6 +4,7 @@ namespace Webkul\Product\Http\Controllers; use Illuminate\Support\Facades\Event; use Webkul\Product\Http\Requests\ProductForm; +use Webkul\Product\Helpers\ProductType; use Webkul\Category\Repositories\CategoryRepository; use Webkul\Product\Repositories\ProductRepository; use Webkul\Product\Repositories\ProductDownloadableLinkRepository; @@ -140,13 +141,13 @@ class ProductController extends Controller public function store() { if (! request()->get('family') - && request()->input('type') == 'configurable' + && ProductType::hasVariants(request()->input('type')) && request()->input('sku') != '') { return redirect(url()->current() . '?type=' . request()->input('type') . '&family=' . request()->input('attribute_family_id') . '&sku=' . request()->input('sku')); } - if (request()->input('type') == 'configurable' + if (ProductType::hasVariants(request()->input('type')) && (! request()->has('super_attributes') || ! count(request()->get('super_attributes')))) { diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index a993a58ae..ecb8ffe9a 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Attribute\Repositories\AttributeOptionRepository; +use Webkul\Product\Helpers\ProductType; use Webkul\Product\Repositories\ProductFlatRepository; use Webkul\Product\Repositories\ProductAttributeValueRepository; use Webkul\Product\Models\ProductAttributeValue; @@ -148,7 +149,7 @@ class ProductFlat { $this->createFlat($product); - if ($product->type == 'configurable') { + if (ProductType::hasVariants($product->type)) { foreach ($product->variants()->get() as $variant) { $this->createFlat($variant, $product); } diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index f1b00ee80..7854d170f 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -227,6 +227,22 @@ class ProductRepository extends Repository return $product; } + /** + * Retrieve product from slug without throwing an exception (might return null) + * + * @param $slug + * + * @return mixed + */ + public function findBySlug($slug) + { + return app('Webkul\Product\Repositories\ProductFlatRepository')->findOneWhere([ + 'url_key' => $slug, + 'locale' => app()->getLocale(), + 'channel' => core()->getCurrentChannelCode(), + ]); + } + /** * Returns newly added product * diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 75abbba1e..39568653d 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -3,6 +3,7 @@ namespace Webkul\Product\Type; use Illuminate\Support\Facades\Storage; +use phpDocumentor\Reflection\Types\Boolean; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Product\Repositories\ProductRepository; use Webkul\Product\Repositories\ProductAttributeValueRepository; @@ -57,7 +58,7 @@ abstract class AbstractType /** * Product Image helper instance - * + * * @var ProductImage */ protected $productImageHelper; @@ -104,6 +105,13 @@ abstract class AbstractType */ protected $canBeMovedFromWishlistToCart = true; + /** + * Has child products aka variants + * + * @var boolean + */ + protected $hasVariants = false; + /** * Create a new product type instance. * @@ -159,17 +167,21 @@ abstract class AbstractType $product->update($data); foreach ($product->attribute_family->custom_attributes as $attribute) { - if ($attribute->type == 'boolean') + if ($attribute->type == 'boolean') { $data[$attribute->code] = isset($data[$attribute->code]) && $data[$attribute->code] ? 1 : 0; + } - if (! isset($data[$attribute->code])) + if (! isset($data[$attribute->code])) { continue; + } - if ($attribute->type == 'date' && $data[$attribute->code] == '') + if ($attribute->type == 'date' && $data[$attribute->code] == '') { $data[$attribute->code] = null; + } - if ($attribute->type == 'multiselect' || $attribute->type == 'checkbox') + if ($attribute->type == 'multiselect' || $attribute->type == 'checkbox') { $data[$attribute->code] = implode(",", $data[$attribute->code]); + } if ($attribute->type == 'image' || $attribute->type == 'file') { $data[$attribute->code] = gettype($data[$attribute->code]) == 'object' @@ -198,16 +210,18 @@ abstract class AbstractType ], $attributeValue->id ); - if ($attribute->type == 'image' || $attribute->type == 'file') + if ($attribute->type == 'image' || $attribute->type == 'file') { Storage::delete($attributeValue->text_value); + } } } - $route = request()->route() ? request()->route()->getName() : ""; + $route = request()->route() ? request()->route()->getName() : ""; if ($route != 'admin.catalog.products.massupdate') { - if (isset($data['categories'])) + if (isset($data['categories'])) { $product->categories()->sync($data['categories']); + } $product->up_sells()->sync($data['up_sell'] ?? []); @@ -243,9 +257,10 @@ abstract class AbstractType */ public function isSaleable() { - if (! $this->product->status) + if (! $this->product->status) { return false; - + } + return true; } @@ -260,7 +275,7 @@ abstract class AbstractType } /** - * Return true if this product can have inventory + * Return true if this product can be composite * * @return boolean */ @@ -269,6 +284,16 @@ abstract class AbstractType return $this->isComposite; } + /** + * Return true if this product can have variants + * + * @return bool + */ + public function hasVariants(): bool + { + return $this->hasVariants; + } + /** * @param integer $qty * @return bool @@ -277,7 +302,7 @@ abstract class AbstractType { return $this->haveSufficientQuantity; } - + /** * Return true if this product can have inventory * @@ -310,8 +335,9 @@ abstract class AbstractType ->pluck('id'); foreach ($this->product->inventories as $inventory) { - if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) + if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) { $total += $inventory->qty; + } } $orderedInventory = $this->product->ordered_inventories() @@ -344,11 +370,13 @@ abstract class AbstractType */ public function getEditableAttributes($group = null, $skipSuperAttribute = true) { - if ($skipSuperAttribute) + if ($skipSuperAttribute) { $this->skipAttributes = array_merge($this->product->super_attributes->pluck('code')->toArray(), $this->skipAttributes); + } - if (! $group) + if (! $group) { return $this->product->attribute_family->custom_attributes()->whereNotIn('attributes.code', $this->skipAttributes)->get(); + } return $group->custom_attributes()->whereNotIn('code', $this->skipAttributes)->get(); } @@ -380,8 +408,9 @@ abstract class AbstractType */ public function getMinimalPrice() { - if ($this->haveSpecialPrice()) + if ($this->haveSpecialPrice()) { return $this->product->special_price; + } return $this->product->price; } @@ -421,11 +450,13 @@ abstract class AbstractType */ public function haveSpecialPrice() { - if (is_null($this->product->special_price) || ! (float) $this->product->special_price) + if (is_null($this->product->special_price) || ! (float) $this->product->special_price) { return false; + } - if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) + if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) { return true; + } return false; } @@ -479,8 +510,9 @@ abstract class AbstractType $data = $this->getQtyRequest($data); - if (! $this->haveSufficientQuantity($data['quantity'])) + if (! $this->haveSufficientQuantity($data['quantity'])) { return trans('shop::app.checkout.cart.quantity.inventory_warning'); + } $price = $this->getFinalPrice(); @@ -514,12 +546,13 @@ abstract class AbstractType */ public function getQtyRequest($data) { - if ($item = Cart::getItemByProduct(['additional' => $data])) + if ($item = Cart::getItemByProduct(['additional' => $data])) { $data['quantity'] += $item->quantity; + } return $data; } - + /** * * @param array $options1 @@ -546,7 +579,7 @@ abstract class AbstractType return true; } - + /** * Returns additional information for items * @@ -590,8 +623,9 @@ abstract class AbstractType { $price = $item->product->getTypeInstance()->getFinalPrice(); - if ($price == $item->base_price) + if ($price == $item->base_price) { return; + } $item->base_price = $price; $item->price = core()->convertPrice($price); diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 79cb4c081..e0f1c3eea 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -22,7 +22,7 @@ class Configurable extends AbstractType /** * These blade files will be included in product edit page - * + * * @var array */ protected $additionalViews = [ @@ -47,6 +47,13 @@ class Configurable extends AbstractType */ protected $showQuantityBox = true; + /** + * Has child products aka variants + * + * @var boolean + */ + protected $hasVariants = true; + /** * @param array $data * @return Product @@ -136,9 +143,15 @@ class Configurable extends AbstractType ]; } + $typeOfVariants = 'simple'; + $productInstance = app(config('product_types.' . $product->type . '.class')); + if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) { + $typeOfVariants = $productInstance->variantsType; + } + $variant = $this->productRepository->getModel()->create([ 'parent_id' => $product->id, - 'type' => 'simple', + 'type' => $typeOfVariants, 'attribute_family_id' => $product->attribute_family_id, 'sku' => $data['sku'], ]); @@ -416,7 +429,7 @@ class Configurable extends AbstractType return $products; } - + /** * * @param array $options1 @@ -451,7 +464,7 @@ class Configurable extends AbstractType ]; } - return $data; + return $data; } /** diff --git a/packages/Webkul/Product/src/resources/manifest.php b/packages/Webkul/Product/src/resources/manifest.php new file mode 100644 index 000000000..2361976a0 --- /dev/null +++ b/packages/Webkul/Product/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Product', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php b/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php index 8af93c227..84715fdbe 100644 --- a/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php +++ b/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php @@ -55,7 +55,7 @@ class DownloadableLinkPurchasedRepository extends Repository */ public function saveLinks($orderItem) { - if ($orderItem->type != 'downloadable' || ! isset($orderItem->additional['links'])) + if (stristr($orderItem->type,'downloadable') === false || ! isset($orderItem->additional['links'])) return; foreach ($orderItem->additional['links'] as $linkId) { diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php index 39c8bf890..72da2f48d 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php @@ -3,6 +3,7 @@ namespace Webkul\Sales\Repositories; use Illuminate\Container\Container as App; +use Illuminate\Support\Facades\Event; use Webkul\Core\Eloquent\Repository; use Webkul\Sales\Contracts\OrderItem; @@ -51,7 +52,7 @@ class OrderItemRepository extends Repository $totalInvoiced = $baseTotalInvoiced = 0; $taxInvoiced = $baseTaxInvoiced = 0; - + $totalRefunded = $baseTotalRefunded = 0; $taxRefunded = $baseTaxRefunded = 0; diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index 7065ef8bd..235a0a1a2 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -3,15 +3,15 @@ namespace Webkul\Sales\Repositories; use Illuminate\Container\Container as App; -use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Event; use Webkul\Core\Eloquent\Repository; -use Webkul\Sales\Contracts\Order; -use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Core\Models\CoreConfig; +use Webkul\Sales\Contracts\Order; +use Webkul\Sales\Models\Order as OrderModel; /** - * Order Reposotory + * Order Repository * * @author Jitendra Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) @@ -35,16 +35,16 @@ class OrderRepository extends Repository /** * Create a new repository instance. * - * @param Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository - * @param Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository + * @param Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository + * * @return void */ public function __construct( OrderItemRepository $orderItemRepository, DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository, App $app - ) - { + ) { $this->orderItemRepository = $orderItemRepository; $this->downloadableLinkPurchasedRepository = $downloadableLinkPurchasedRepository; @@ -58,13 +58,14 @@ class OrderRepository extends Repository * @return Mixed */ - function model() + public function model() { return Order::class; } /** * @param array $data + * * @return mixed */ public function create(array $data) @@ -95,12 +96,15 @@ class OrderRepository extends Repository $order->payment()->create($data['payment']); - if (isset($data['shipping_address'])) + if (isset($data['shipping_address'])) { $order->addresses()->create($data['shipping_address']); + } $order->addresses()->create($data['billing_address']); foreach ($data['items'] as $item) { + Event::fire('checkout.order.orderitem.save.before', $data); + $orderItem = $this->orderItemRepository->create(array_merge($item, ['order_id' => $order->id])); if (isset($item['children']) && $item['children']) { @@ -112,6 +116,8 @@ class OrderRepository extends Repository $this->orderItemRepository->manageInventory($orderItem); $this->downloadableLinkPurchasedRepository->saveLinks($orderItem, 'available'); + + Event::fire('checkout.order.orderitem.save.after', $data); } Event::fire('checkout.order.save.after', $order); @@ -128,20 +134,23 @@ class OrderRepository extends Repository /** * @param int $orderId + * * @return mixed */ public function cancel($orderId) { $order = $this->findOrFail($orderId); - if (! $order->canCancel()) + if (! $order->canCancel()) { return false; + } Event::fire('sales.order.cancel.before', $order); foreach ($order->items as $item) { - if (! $item->qty_to_cancel) + if (! $item->qty_to_cancel) { continue; + } $orderItems = []; @@ -152,11 +161,12 @@ class OrderRepository extends Repository } else { $orderItems[] = $item; } - + foreach ($orderItems as $orderItem) { - if ($orderItem->product) + if ($orderItem->product) { $this->orderItemRepository->returnQtyToProductInventory($orderItem); - + } + if ($orderItem->qty_ordered) { $orderItem->qty_canceled += $orderItem->qty_to_cancel; $orderItem->save(); @@ -188,20 +198,20 @@ class OrderRepository extends Repository { $config = new CoreConfig(); - $invoiceNumberPrefix = $config->where('code','=',"sales.orderSettings.order_number.order_number_prefix")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_prefix")->first()->value : false; - - $invoiceNumberLength = $config->where('code','=',"sales.orderSettings.order_number.order_number_length")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_length")->first()->value : false; - - $invoiceNumberSuffix = $config->where('code','=',"sales.orderSettings.order_number.order_number_suffix")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_suffix")->first()->value: false; + foreach ([ 'Prefix' => 'prefix', + 'Length' => 'length', + 'Suffix' => 'suffix', ] as + $varSuffix => $confKey) + { + $var = "invoiceNumber{$varSuffix}"; + $$var = $config->where('code', '=', "sales.orderSettings.order_number.order_number_{$confKey}")->first() ?: false; + } $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; - if ($invoiceNumberLength && ( $invoiceNumberPrefix || $invoiceNumberSuffix) ) { - $invoiceNumber = $invoiceNumberPrefix . sprintf("%0{$invoiceNumberLength}d", 0) . ($lastId + 1) . $invoiceNumberSuffix; + if ($invoiceNumberLength && ($invoiceNumberPrefix || $invoiceNumberSuffix)) { + $invoiceNumber = ($invoiceNumberPrefix->value) . sprintf("%0{$invoiceNumberLength->value}d", 0) . ($lastId + 1) . ($invoiceNumberSuffix->value); } else { $invoiceNumber = $lastId + 1; } @@ -211,13 +221,14 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function isInCompletedState($order) { $totalQtyOrdered = $totalQtyInvoiced = $totalQtyShipped = $totalQtyRefunded = $totalQtyCanceled = 0; - foreach ($order->items()->get() as $item) { + foreach ($order->items()->get() as $item) { $totalQtyOrdered += $item->qty_ordered; $totalQtyInvoiced += $item->qty_invoiced; @@ -233,14 +244,16 @@ class OrderRepository extends Repository if ($totalQtyOrdered != ($totalQtyRefunded + $totalQtyCanceled) && $totalQtyOrdered == $totalQtyInvoiced + $totalQtyCanceled - && $totalQtyOrdered == $totalQtyShipped + $totalQtyRefunded + $totalQtyCanceled) + && $totalQtyOrdered == $totalQtyShipped + $totalQtyRefunded + $totalQtyCanceled) { return true; + } return false; } /** * @param mixed $order + * * @return void */ public function isInCanceledState($order) @@ -257,13 +270,14 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function isInClosedState($order) { $totalQtyOrdered = $totalQtyRefunded = $totalQtyCanceled = 0; - foreach ($order->items()->get() as $item) { + foreach ($order->items()->get() as $item) { $totalQtyOrdered += $item->qty_ordered; $totalQtyRefunded += $item->qty_refunded; $totalQtyCanceled += $item->qty_canceled; @@ -274,19 +288,22 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function updateOrderStatus($order) { $status = 'processing'; - if ($this->isInCompletedState($order)) + if ($this->isInCompletedState($order)) { $status = 'completed'; + } - if ($this->isInCanceledState($order)) + if ($this->isInCanceledState($order)) { $status = 'canceled'; - else if ($this->isInClosedState($order)) + } elseif ($this->isInClosedState($order)) { $status = 'closed'; + } $order->status = $status; $order->save(); @@ -294,6 +311,7 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return mixed */ public function collectTotals($order) @@ -352,4 +370,4 @@ class OrderRepository extends Repository return $order; } -} \ No newline at end of file +} diff --git a/packages/Webkul/Sales/src/resources/manifest.php b/packages/Webkul/Sales/src/resources/manifest.php new file mode 100644 index 000000000..5845b7688 --- /dev/null +++ b/packages/Webkul/Sales/src/resources/manifest.php @@ -0,0 +1,6 @@ + 'Webkul Bagisto Sales', + 'version' => '0.0.1' + ]; diff --git a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php index 74906ae24..ced3940c6 100644 --- a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php +++ b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php @@ -22,7 +22,7 @@ class DownloadableProductDataGrid extends DataGrid $queryBuilder = DB::table('downloadable_link_purchased') ->leftJoin('orders', 'downloadable_link_purchased.order_id', '=', 'orders.id') ->addSelect('downloadable_link_purchased.*', 'orders.increment_id') - ->addSelect(DB::raw('(downloadable_link_purchased.download_bought - downloadable_link_purchased.download_used) as remaining_downloads')) + ->addSelect(DB::raw('('.DB::getTablePrefix().'downloadable_link_purchased.download_bought - '.DB::getTablePrefix().'downloadable_link_purchased.download_used) as remaining_downloads')) ->where('downloadable_link_purchased.customer_id', auth()->guard('customer')->user()->id); $this->addFilter('status', 'downloadable_link_purchased.status'); @@ -97,7 +97,7 @@ class DownloadableProductDataGrid extends DataGrid 'wrapper' => function ($value) { if (! $value->download_bought) return trans('shop::app.customer.account.downloadable_products.unlimited'); - + return $value->remaining_downloads; }, ]); diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php new file mode 100644 index 000000000..f8087b39c --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194541_add_column_url_path_to_category_translations.php @@ -0,0 +1,33 @@ +string('url_path', 2048) + ->comment('maintained by database triggers'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('category_translations', function (Blueprint $table) { + $table->dropColumn('url_path'); + }); + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php new file mode 100644 index 000000000..72d995819 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194608_add_stored_function_to_get_url_path_of_category.php @@ -0,0 +1,68 @@ + 1 + THEN + SELECT + GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath + FROM + categories AS node, + categories AS parent + JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id + WHERE + node._lft >= parent._lft + AND node._rgt <= parent._rgt + AND node.id = categoryId + AND parent.id <> 1 + AND parent_translations.locale = localeCode + GROUP BY + node.id; + + IF urlPath IS NULL + THEN + SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId); + END IF; + ELSE + SET urlPath = ''; + END IF; + + RETURN urlPath; + END; +SQL; + + DB::unprepared($functionSQL); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::unprepared('DROP FUNCTION IF EXISTS `get_url_path_of_category`;'); + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php new file mode 100644 index 000000000..b62a6133f --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194627_add_trigger_to_category_translations.php @@ -0,0 +1,98 @@ +getTriggerBody(); + $insertTrigger = <<< SQL + CREATE TRIGGER %s + BEFORE INSERT ON category_translations + FOR EACH ROW + BEGIN + $triggerBody + END; +SQL; + + $updateTrigger = <<< SQL + CREATE TRIGGER %s + BEFORE UPDATE ON category_translations + FOR EACH ROW + BEGIN + $triggerBody + END; +SQL; + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf($insertTrigger, self::TRIGGER_NAME_INSERT)); + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + DB::unprepared(sprintf($updateTrigger, self::TRIGGER_NAME_UPDATE)); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + } + + /** + * Returns trigger body as string + * + * @return string + */ + private function getTriggerBody() + { + return << 1 + THEN + + SELECT + GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO parentUrlPath + FROM + categories AS node, + categories AS parent + JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id + WHERE + node._lft >= parent._lft + AND node._rgt <= parent._rgt + AND node.id = (SELECT parent_id FROM categories WHERE id = NEW.category_id) + AND parent.id <> 1 + AND parent_translations.locale = NEW.locale + GROUP BY + node.id; + + IF parentUrlPath IS NULL + THEN + SET urlPath = NEW.slug; + ELSE + SET urlPath = concat(parentUrlPath, '/', NEW.slug); + END IF; + + SET NEW.url_path = urlPath; + + END IF; +SQL; + + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php new file mode 100644 index 000000000..7b8565bd1 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194648_add_url_path_to_existing_category_translations.php @@ -0,0 +1,35 @@ +getTable(); + + foreach (DB::table($categoryTranslationsTableName)->get() as $categoryTranslation) { + $urlPathQueryResult = DB::selectOne($sqlStoredFunction, [ + 'category_id' => $categoryTranslation->category_id, + 'locale_code' => $categoryTranslation->locale, + ]); + $url_path = $urlPathQueryResult ? $urlPathQueryResult->url_path : ''; + + DB::table($categoryTranslationsTableName) + ->where('id', $categoryTranslation->id) + ->update(['url_path' => $url_path]); + } + } +} diff --git a/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php new file mode 100644 index 000000000..f58739d75 --- /dev/null +++ b/packages/Webkul/Shop/src/Database/Migrations/2019_11_21_194703_add_trigger_to_categories.php @@ -0,0 +1,99 @@ +getTriggerBody(); + + $insertTrigger = <<< SQL + CREATE TRIGGER %s + AFTER INSERT ON categories + FOR EACH ROW + BEGIN + $triggerBody + END; +SQL; + + $updateTrigger = <<< SQL + CREATE TRIGGER %s + AFTER UPDATE ON categories + FOR EACH ROW + BEGIN + $triggerBody + END; +SQL; + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf($insertTrigger, self::TRIGGER_NAME_INSERT)); + + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + DB::unprepared(sprintf($updateTrigger, self::TRIGGER_NAME_UPDATE)); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_INSERT)); + DB::unprepared(sprintf('DROP TRIGGER IF EXISTS %s;', self::TRIGGER_NAME_UPDATE)); + } + + /** + * Returns trigger body as string + * + * @return string + */ + private function getTriggerBody(): string + { + return <<< SQL + DECLARE urlPath VARCHAR(255); + DECLARE localeCode VARCHAR(255); + DECLARE done INT; + DECLARE curs CURSOR FOR (SELECT category_translations.locale + FROM category_translations + WHERE category_id = NEW.id); + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + + + IF EXISTS ( + SELECT * + FROM category_translations + WHERE category_id = NEW.id + ) + THEN + + OPEN curs; + + SET done = 0; + REPEAT + FETCH curs INTO localeCode; + + SELECT get_url_path_of_category(NEW.id, localeCode) INTO urlPath; + + UPDATE category_translations + SET url_path = urlPath + WHERE category_translations.category_id = NEW.id; + + UNTIL done END REPEAT; + + CLOSE curs; + + END IF; +SQL; + } +} diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index a080d0fd3..b23c42b4c 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -96,7 +96,7 @@ class CartController extends Controller $product = $this->productRepository->find($id); - return redirect()->route('shop.products.index', ['slug' => $product->url_key]); + return redirect()->route('shop.productOrCategory.index', ['slug' => $product->url_key]); } return redirect()->back(); diff --git a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php index 03d428067..69defe0a9 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CategoryController.php @@ -38,17 +38,4 @@ class CategoryController extends Controller $this->_config = request('_config'); } - - /** - * Display a listing of the resource. - * - * @param string $slug - * @return \Illuminate\View\View - */ - public function index($slug) - { - $category = $this->categoryRepository->findBySlugOrFail($slug); - - return view($this->_config['view'], compact('category')); - } } diff --git a/packages/Webkul/Shop/src/Http/Controllers/OrderController.php b/packages/Webkul/Shop/src/Http/Controllers/OrderController.php index a254c056e..806edee66 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/OrderController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OrderController.php @@ -60,7 +60,7 @@ class OrderController extends Controller /** * Display a listing of the resource. * - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function index() { @@ -71,7 +71,7 @@ class OrderController extends Controller * Show the view for the specified resource. * * @param int $id - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function view($id) { diff --git a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php index ef6144581..2f24b78e8 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/ProductController.php @@ -79,21 +79,6 @@ class ProductController extends Controller $this->_config = request('_config'); } - /** - * Display a listing of the resource. - * - * @param string $slug - * @return \Illuminate\View\View - */ - public function index($slug) - { - $product = $this->productRepository->findBySlugOrFail($slug); - - $customer = auth()->guard('customer')->user(); - - return view($this->_config['view'], compact('product', 'customer')); - } - /** * Download image or file * diff --git a/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php b/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php new file mode 100644 index 000000000..d8dfad45f --- /dev/null +++ b/packages/Webkul/Shop/src/Http/Controllers/ProductsCategoriesProxyController.php @@ -0,0 +1,78 @@ +categoryRepository = $categoryRepository; + $this->productRepository = $productRepository; + + $this->_config = request('_config'); + } + + /** + * Display a listing of the resource which can be a category or a product. + * + * + * @param string $slugOrPath + * + * @return \Illuminate\View\View + */ + public function index(string $slugOrPath) + { + + if ($category = $this->categoryRepository->findByPath($slugOrPath)) { + + return view($this->_config['category_view'], compact('category')); + } + + if ($product = $this->productRepository->findBySlug($slugOrPath)) { + + $customer = auth()->guard('customer')->user(); + + return view($this->_config['product_view'], compact('product', 'customer')); + } + + abort(404); + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php b/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php index b27b2a1b9..450271b1e 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php @@ -44,8 +44,7 @@ class ReviewController extends Controller public function __construct( ProductRepository $productRepository, ProductReviewRepository $productReviewRepository - ) - { + ) { $this->productRepository = $productRepository; $this->productReviewRepository = $productReviewRepository; @@ -57,15 +56,17 @@ class ReviewController extends Controller * Show the form for creating a new resource. * * @param string $slug - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function create($slug) { - $product = $this->productRepository->findBySlugOrFail($slug); + if (auth()->guard('customer')->check() || core()->getConfigData('catalog.products.review.guest_review')) { + $product = $this->productRepository->findBySlugOrFail($slug); - $guest_review = core()->getConfigData('catalog.products.review.guest_review'); + return view($this->_config['view'], compact('product', 'guest_review')); + } - return view($this->_config['view'], compact('product', 'guest_review')); + abort(404); } /** @@ -103,7 +104,7 @@ class ReviewController extends Controller * Display reviews of particular product. * * @param string $slug - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function show($slug) { diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 1eb433e8e..129c625fa 100755 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -13,11 +13,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function //unsubscribe Route::get('/unsubscribe/{token}', 'Webkul\Shop\Http\Controllers\SubscriptionController@unsubscribe')->name('shop.unsubscribe'); - //Store front header nav-menu fetch - Route::get('/categories/{slug}', 'Webkul\Shop\Http\Controllers\CategoryController@index')->defaults('_config', [ - 'view' => 'shop::products.index' - ])->name('shop.categories.index'); - //Store front search Route::get('/search', 'Webkul\Shop\Http\Controllers\SearchController@index')->defaults('_config', [ 'view' => 'shop::search.search' @@ -89,11 +84,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function //Shop buynow button action Route::get('move/wishlist/{id}', 'Webkul\Shop\Http\Controllers\CartController@moveToWishlist')->name('shop.movetowishlist'); - //Show Product Details Page(For individually Viewable Product) - Route::get('/products/{slug}', 'Webkul\Shop\Http\Controllers\ProductController@index')->defaults('_config', [ - 'view' => 'shop::products.view' - ])->name('shop.products.index'); - Route::get('/downloadable/download-sample/{type}/{id}', 'Webkul\Shop\Http\Controllers\ProductController@downloadSample')->name('shop.downloadable.download_sample'); // Show Product Review Form @@ -307,5 +297,13 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function Route::get('page/{slug}', 'Webkul\CMS\Http\Controllers\Shop\PagePresenterController@presenter')->name('shop.cms.page'); + Route::get('{slugOrPath}', \Webkul\Shop\Http\Controllers\ProductsCategoriesProxyController::class . '@index') + ->defaults('_config', [ + 'product_view' => 'shop::products.view', + 'category_view' => 'shop::products.index' + ]) + ->where('slugOrPath', '^([a-z0-9-]+\/?)+$') + ->name('shop.productOrCategory.index'); + Route::fallback('Webkul\Shop\Http\Controllers\HomeController@notFound'); }); diff --git a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php index 96ba6a3e3..271cb6f85 100755 --- a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php +++ b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php @@ -31,7 +31,7 @@ class SubscriptionEmail extends Mailable public function build() { return $this->to($this->subscriptionData['email']) - ->from(env('SHOP_MAIL_FROM')) + ->from(config('mail.from')) ->subject(trans('shop::app.mail.customer.subscription.subject')) ->view('shop::emails.customer.subscription-email')->with('data', ['content' => 'You Are Subscribed', 'token' => $this->subscriptionData['token']]); } diff --git a/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php b/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php index e97fd1d9d..06c0d1cee 100755 --- a/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php +++ b/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php @@ -25,6 +25,8 @@ class ShopServiceProvider extends ServiceProvider */ public function boot(Router $router) { + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop'); diff --git a/packages/Webkul/Shop/src/Resources/assets/js/lang/locales.js b/packages/Webkul/Shop/src/Resources/assets/js/lang/locales.js index 3b0e3f538..d01d696c7 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/lang/locales.js +++ b/packages/Webkul/Shop/src/Resources/assets/js/lang/locales.js @@ -3,26 +3,26 @@ export const messages = { required : (field) => 'حقل' + field + ' مطلوب', alpha : (field) => field + ' يجب ان يحتوي على حروف فقط', alpha_num : (field) => field + ' قد يحتوي فقط على حروف وارقام', - min : (field) => 'الحقل ' + field + ' يجب ان يحتوي على {length} حروف على الأقل', + min : (field, length) => 'الحقل ' + field + ' يجب ان يحتوي على ' + length + ' حروف على الأقل', numeric : (field) => field + ' يمكن ان يحتوي فقط على ارقام', oneOf : (field) => 'الحقل ' + field + 'يجب ان يكون قيمة صحيحة', regex : (field) => 'الحقل' + field+ ' غير صحيح', required_if : (field) => 'حقل' + field + ' مطلوب', - size : (field) => field + ' يجب ان يكون اقل من {size} كيلوبايت', - min_value : (field) => 'قيمة الحقل' + field + ' يجب ان تكون اكبر من {min} او تساويها', + size : (field, size) => field + ' يجب ان يكون اقل من ' + size + ' كيلوبايت', + min_value : (field, min) => 'قيمة الحقل' + field + ' يجب ان تكون اكبر من ' + min + ' او تساويها', alpha_spaces : (field) => field + ' قد يحتوي فقط على حروف ومسافات', - between : (field) => 'قيمة ' +field+ ' يجب ان تكون ما بين {min} و {max}', + between : (field, min, max) => 'قيمة ' +field+ ' يجب ان تكون ما بين ' + min + ' و ' + max, confirmed : (field) => field + ' لا يماثل التأكيد', - digits : (field) => field + ' يجب ان تحتوي فقط على ارقام والا يزيد عددها عن {length} رقم', - dimensions : (field) => field + ' يجب ان تكون بمقاس {width} بكسل في {height} بكسل', + digits : (field, length) => field + ' يجب ان تحتوي فقط على ارقام والا يزيد عددها عن ' + length + ' رقم', + dimensions : (field, width, height) => field + ' يجب ان تكون بمقاس ' + width + ' بكسل في ' + height + ' بكسل', email : (field) => field + ' يجب ان يكون بريدا اليكتروني صحيح', excluded : (field) => 'الحقل' + field +'غير صحيح', ext : (field) =>'نوع مل'+ field + 'غير صحيح', image : (field) => field + ' يجب ان تكون صورة', integer : (field) => 'الحقل ' +field + ' يجب ان يكون عدداً صحيحاً', - length : (field) => 'حقل'+ field + ' يجب الا يزيد عن {length}', - max_value : (field) => 'قيمة الحقل '+ field + ' يجب ان تكون اصغر من {min} او تساويها', - max : (field) => 'الحقل' + field + 'يجب ان يحتوي على {length} حروف على الأكثر', + length : (field, length) => 'حقل'+ field + ' يجب الا يزيد عن ' + length, + max_value : (field, min) => 'قيمة الحقل '+ field + ' يجب ان تكون اصغر من ' + min + ' او تساويها', + max : (field, length) => 'الحقل' + field + 'يجب ان يحتوي على ' + length + ' حروف على الأكثر', mimes : (field) => 'نوع ملف' + field + 'غير صحيح' } } diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php index 0cab52989..269fc5ca4 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php @@ -54,7 +54,7 @@ @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php index 2cdd1d776..7956cc53f 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php @@ -296,10 +296,11 @@ else paymentHtml = Vue.compile(response.data.html) - this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] + 1; + this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] - 1; this_this.current_step = this_this.step_numbers[response.data.jump_to_section]; shippingMethods = response.data.shippingMethods; + paymentMethods = response.data.paymentMethods; this_this.getOrderSummary(); }) @@ -320,7 +321,7 @@ this_this.disable_button = false; paymentHtml = Vue.compile(response.data.html) - this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] + 1; + this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] - 1; this_this.current_step = this_this.step_numbers[response.data.jump_to_section]; paymentMethods = response.data.paymentMethods; @@ -344,7 +345,7 @@ this_this.disable_button = false; reviewHtml = Vue.compile(response.data.html) - this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] + 1; + this_this.completed_step = this_this.step_numbers[response.data.jump_to_section] - 1; this_this.current_step = this_this.step_numbers[response.data.jump_to_section]; this_this.getOrderSummary(); @@ -608,7 +609,7 @@ methods: { onSubmit: function() { var this_this = this; - + const emptyCouponErrorText = "Please enter a coupon code"; axios.post('{{ route('shop.checkout.check.coupons') }}', {code: this_this.coupon_code}) .then(function(response) { this_this.$emit('onApplyCoupon'); @@ -618,7 +619,10 @@ .catch(function(error) { this_this.couponChanged = true; - this_this.error_message = error.response.data.message; + this_this.error_message = (error.response.data.message === "The given data was invalid.")? + emptyCouponErrorText : + (error.response.data.message === "Cannot Apply Coupon")? + "Sorry, this Coupon code is invalid":error.response.data.message; }); }, diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php index 20f2c30d9..ac34652ba 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php @@ -19,12 +19,10 @@ - {{-- --}} + + {{ $payment['method_title'] }} + - - - {{ $payment['method_title'] }} -
diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/profile/index.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/profile/index.blade.php index 8389fe924..02abd9341 100755 --- a/packages/Webkul/Shop/src/Resources/views/customers/account/profile/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/customers/account/profile/index.blade.php @@ -30,6 +30,9 @@