diff --git a/.env.example b/.env.example index e710496ca..c3e5febd2 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,10 @@ APP_VERSION=1.0.0 APP_KEY= APP_DEBUG=true APP_URL=http://localhost -APP_TIMEZONE='Asia/Kolkata' +APP_TIMEZONE= +APP_LOCALE= LOG_CHANNEL=stack -APP_CURRENCY=USD +APP_CURRENCY= DB_CONNECTION=mysql DB_HOST=127.0.0.1 diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md index 770fab9c5..7d4fe777c 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.md +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.md @@ -7,7 +7,7 @@ about: 'Report a general library issue.' ### Title **Just a quick sentence to brief your trouble with Bagisto or something associated with it.** -**Please be calm, short and emaphasize on points.** +**Please be calm, short and emphasize on points.** ### Issue Description **Description helps the developers to understand the bug. It describes the problem encountered or some after effect of some kind.** diff --git a/app/Console/Commands/GenerateProducts.php b/app/Console/Commands/GenerateProducts.php index b1899c0b5..5a94f7d4b 100644 --- a/app/Console/Commands/GenerateProducts.php +++ b/app/Console/Commands/GenerateProducts.php @@ -3,9 +3,13 @@ namespace App\Console\Commands; use Illuminate\Console\Command; -use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Helpers\GenerateProduct; +/** + * Class GenerateProducts + * + * @package App\Console\Commands + */ class GenerateProducts extends Command { /** @@ -54,12 +58,24 @@ class GenerateProducts extends Command if (! is_string($this->argument('value')) || ! is_numeric($this->argument('quantity'))) { $this->info('Illegal parameters or value of parameters are passed'); } else { - if (strtolower($this->argument('value')) == 'product' || strtolower($this->argument('value')) == 'products') { - $quantity = intval($this->argument('quantity')); + if (strtolower($this->argument('value')) == 'product' || strtolower($this->argument('value')) == 'products') { + $quantity = (int)$this->argument('quantity'); + // @see https://laravel.com/docs/6.x/artisan#writing-output + // @see https://symfony.com/doc/current/components/console/helpers/progressbar.html + $bar = $this->output->createProgressBar($quantity); + + $this->line("Generating $quantity {$this->argument('value')}."); + + $bar->start(); + + $generatedProducts = 0; + $this->generateProduct->generateDemoBrand(); while ($quantity > 0) { try { $result = $this->generateProduct->create(); + $generatedProducts++; + $bar->advance(); } catch (\Exception $e) { report($e); continue; @@ -68,10 +84,13 @@ class GenerateProducts extends Command $quantity--; } - if ($result) - $this->info('Product(s) created successfully.'); - else + + if ($result) { + $bar->finish(); + $this->info("\n$generatedProducts Product(s) created successfully."); + } else { $this->info('Product(s) cannot be created successfully.'); + } } else { $this->line('Sorry, this generate option is invalid.'); } diff --git a/app/Console/Commands/install.php b/app/Console/Commands/install.php index b1c2b3380..f8fe1d7c6 100644 --- a/app/Console/Commands/install.php +++ b/app/Console/Commands/install.php @@ -78,35 +78,57 @@ class install extends Command { $envExists = File::exists(base_path() . '/.env'); if (!$envExists) { - $this->info('Creating .env file'); + $this->info('Creating the environment configuration file.'); $this->createEnvFile(); } else { - $this->info('Great! .env file aready exists'); + $this->info('Great! your environment configuration file aready exists.'); } } + /** + * Create a new .env file. + */ public function createEnvFile() { try { File::copy('.env.example', '.env'); Artisan::call('key:generate'); $this->envUpdate('APP_URL=http://localhost', ':8000'); + + $locale = $this->choice('Please select the default locale or press enter to continue', ['ar', 'en', 'fa', 'nl', 'pt_BR'], 1); + $this->envUpdate('APP_LOCALE=', $locale); + + $TimeZones = timezone_identifiers_list(); + $timezone = $this->anticipate('Please enter the default timezone', $TimeZones, date_default_timezone_get()); + $this->envUpdate('APP_TIMEZONE=', $timezone); + + $currency = $this->choice('Please enter the default currency', ['USD', 'EUR'], 'USD'); + $this->envUpdate('APP_CURRENCY=', $currency); + + $this->addDatabaseDetails(); } catch (\Exception $e) { - $this->error('Error in creating .env file, please create manually and then run `php artisan migrate` again'); + $this->error('Error in creating .env file, please create it manually and then run `php artisan migrate` again.'); } } + /** + * Add the database credentials to the .env file. + */ public function addDatabaseDetails() { - $dbName = $this->ask('What is your database name to be used by bagisto'); - $dbUser = $this->anticipate('What is your database username', ['root']); - $dbPass = $this->secret('What is your database password'); + $dbName = $this->ask('What is the database name to be used by bagisto?'); + $dbUser = $this->anticipate('What is your database username?', ['root']); + $dbPass = $this->secret('What is your database password?'); + $this->envUpdate('DB_DATABASE=', $dbName); $this->envUpdate('DB_USERNAME=', $dbUser); $this->envUpdate('DB_PASSWORD=', $dbPass); } + /** + * Update the .env values. + */ public static function envUpdate($key, $value) { $path = base_path() . '/.env'; diff --git a/config/app.php b/config/app.php index 9582e5f21..1aa6d5677 100755 --- a/config/app.php +++ b/config/app.php @@ -78,7 +78,7 @@ return [ | */ - 'locale' => 'en', + 'locale' => env('APP_LOCALE', 'en'), /* |-------------------------------------------------------------------------- @@ -116,8 +116,8 @@ return [ | Here you may specify the base currency code for your application. | */ - - 'currency' => env('APP_CURRENCY','USD'), + + 'currency' => env('APP_CURRENCY', 'USD'), /* |-------------------------------------------------------------------------- diff --git a/packages/Webkul/API/Http/Controllers/Shop/CartController.php b/packages/Webkul/API/Http/Controllers/Shop/CartController.php index e38d0aa28..545185a11 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CartController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CartController.php @@ -56,8 +56,7 @@ class CartController extends Controller CartRepository $cartRepository, CartItemRepository $cartItemRepository, WishlistRepository $wishlistRepository - ) - { + ) { $this->guard = request()->has('token') ? 'api' : 'customer'; auth()->setDefaultDriver($this->guard); @@ -93,7 +92,8 @@ class CartController extends Controller /** * Store a newly created resource in storage. * - * @param int $id + * @param int $id + * * @return \Illuminate\Http\Response */ public function store($id) @@ -101,7 +101,7 @@ class CartController extends Controller if (request()->get('is_buy_now')) { Event::dispatch('shop.item.buy-now', $id); } - + Event::dispatch('checkout.cart.item.add.before', $id); $result = Cart::addProduct($id, request()->except('_token')); @@ -110,8 +110,8 @@ class CartController extends Controller $message = session()->get('warning') ?? session()->get('error'); return response()->json([ - 'error' => session()->get('warning') - ], 400); + 'error' => session()->get('warning') + ], 400); } if ($customer = auth($this->guard)->user()) { @@ -125,9 +125,9 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'message' => 'Product added to cart successfully.', - 'data' => $cart ? new CartResource($cart) : null - ]); + 'message' => __('shop::app.checkout.cart.item.success'), + 'data' => $cart ? new CartResource($cart) : null + ]); } /** @@ -137,11 +137,11 @@ class CartController extends Controller */ public function update() { - foreach (request()->get('qty') as$qty) { + foreach (request()->get('qty') as $qty) { if ($qty <= 0) { return response()->json([ - 'message' => trans('shop::app.checkout.cart.quantity.illegal') - ], 401); + 'message' => trans('shop::app.checkout.cart.quantity.illegal') + ], 401); } } @@ -160,9 +160,9 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'message' => 'Cart updated successfully.', - 'data' => $cart ? new CartResource($cart) : null - ]); + 'message' => __('shop::app.checkout.cart.quantity.success'), + 'data' => $cart ? new CartResource($cart) : null + ]); } /** @@ -181,15 +181,16 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'message' => 'Cart removed successfully.', - 'data' => $cart ? new CartResource($cart) : null - ]); + 'message' => __('shop::app.checkout.cart.item.success-remove'), + 'data' => $cart ? new CartResource($cart) : null + ]); } /** * Remove the specified resource from storage. * - * @param int $id + * @param int $id + * * @return \Illuminate\Http\Response */ public function destroyItem($id) @@ -205,9 +206,9 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'message' => 'Cart removed successfully.', - 'data' => $cart ? new CartResource($cart) : null - ]); + 'message' => __('shop::app.checkout.cart.item.success-remove'), + 'data' => $cart ? new CartResource($cart) : null + ]); } /** @@ -229,8 +230,8 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'message' => 'Cart item moved to wishlist successfully.', - 'data' => $cart ? new CartResource($cart) : null - ]); + 'message' => __('shop::app.checkout.cart.move-to-wishlist-success'), + 'data' => $cart ? new CartResource($cart) : null + ]); } -} +} \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rules/create.blade.php b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rules/create.blade.php index 96a51f118..087a84a4c 100644 --- a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rules/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rules/create.blade.php @@ -56,7 +56,7 @@
- +