diff --git a/config/concord.php b/config/concord.php index 3585e74c6..ede7ec84d 100755 --- a/config/concord.php +++ b/config/concord.php @@ -1,5 +1,4 @@ [ /** @@ -8,7 +7,6 @@ return [ * VendorB\ModuleY\Providers\ModuleServiceProvider::class * */ - \Webkul\Attribute\Providers\ModuleServiceProvider::class, \Webkul\Category\Providers\ModuleServiceProvider::class, \Webkul\Checkout\Providers\ModuleServiceProvider::class, diff --git a/config/debugbar.php b/config/debugbar.php index 72ccd7bd3..8350e1c8d 100755 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -16,7 +16,7 @@ return [ 'enabled' => env('DEBUGBAR_ENABLED', null), 'except' => [ - 'telescope*' + // ], /* @@ -143,7 +143,7 @@ return [ 'timeline' => false, // Add the queries to the timeline 'explain' => [ // Show EXPLAIN output on queries 'enabled' => false, - 'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ + 'types' => ['SELECT'], // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ ], 'hints' => true, // Show hints for common mistakes ], diff --git a/config/excel.php b/config/excel.php index 37695184f..af3e8bb99 100755 --- a/config/excel.php +++ b/config/excel.php @@ -3,7 +3,6 @@ use Maatwebsite\Excel\Excel; return [ - 'exports' => [ /* @@ -17,6 +16,17 @@ return [ */ 'chunk_size' => 1000, + /* + |-------------------------------------------------------------------------- + | Temporary path + |-------------------------------------------------------------------------- + | + | When exporting files, we use a temporary file, before storing + | or downloading. Here you can customize that path. + | + */ + 'temp_path' => sys_get_temp_dir(), + /* |-------------------------------------------------------------------------- | Pre-calculate formulas during export @@ -59,23 +69,6 @@ return [ */ 'formatter' => 'slug', ], - - /* - |-------------------------------------------------------------------------- - | CSV Settings - |-------------------------------------------------------------------------- - | - | Configure e.g. delimiter, enclosure and line ending for CSV imports. - | - */ - 'csv' => [ - 'delimiter' => ',', - 'enclosure' => '"', - 'line_ending' => PHP_EOL, - 'use_bom' => false, - 'include_separator_line' => false, - 'excel_compatibility' => false, - ], ], /* @@ -116,71 +109,4 @@ return [ */ 'pdf' => Excel::DOMPDF, ], - - 'value_binder' => [ - - /* - |-------------------------------------------------------------------------- - | Default Value Binder - |-------------------------------------------------------------------------- - | - | PhpSpreadsheet offers a way to hook into the process of a value being - | written to a cell. In there some assumptions are made on how the - | value should be formatted. If you want to change those defaults, - | you can implement your own default value binder. - | - */ - 'default' => Maatwebsite\Excel\DefaultValueBinder::class, - ], - - 'transactions' => [ - - /* - |-------------------------------------------------------------------------- - | Transaction Handler - |-------------------------------------------------------------------------- - | - | By default the import is wrapped in a transaction. This is useful - | for when an import may fail and you want to retry it. With the - | transactions, the previous import gets rolled-back. - | - | You can disable the transaction handler by setting this to null. - | Or you can choose a custom made transaction handler here. - | - | Supported handlers: null|db - | - */ - 'handler' => 'db', - ], - - 'temporary_files' => [ - - /* - |-------------------------------------------------------------------------- - | Local Temporary Path - |-------------------------------------------------------------------------- - | - | When exporting and importing files, we use a temporary file, before - | storing reading or downloading. Here you can customize that path. - | - */ - 'local_path' => sys_get_temp_dir(), - - /* - |-------------------------------------------------------------------------- - | Remote Temporary Disk - |-------------------------------------------------------------------------- - | - | When dealing with a multi server setup with queues in which you - | cannot rely on having a shared local temporary path, you might - | want to store the temporary file on a shared disk. During the - | queue executing, we'll retrieve the temporary file from that - | location instead. When left to null, it will always use - | the local path. This setting only has effect when using - | in conjunction with queued imports and exports. - | - */ - 'remote_disk' => null, - - ], ]; diff --git a/config/tinker.php b/config/tinker.php index 0d2bf00e7..1341c1b03 100755 --- a/config/tinker.php +++ b/config/tinker.php @@ -2,21 +2,6 @@ return [ - /* - |-------------------------------------------------------------------------- - | Console Commands - |-------------------------------------------------------------------------- - | - | This option allows you to add additional Artisan commands that should - | be available within the Tinker environment. Once the command is in - | this array you may execute the command in Tinker using its name. - | - */ - - 'commands' => [ - // App\Console\Commands\ExampleCommand::class, - ], - /* |-------------------------------------------------------------------------- | Alias Blacklist @@ -28,8 +13,6 @@ return [ | */ - 'dont_alias' => [ - 'App\Nova', - ], + 'dont_alias' => [], ]; diff --git a/config/translatable.php b/config/translatable.php index 87f898b4e..1ef910d3e 100755 --- a/config/translatable.php +++ b/config/translatable.php @@ -39,8 +39,6 @@ return [ | As a default locale, Translatable takes the locale of Laravel's | translator. If for some reason you want to override this, | you can specify what default should be used here. - | If you set a value here it will only use the current config value - | and never fallback to the translator one. | */ 'locale' => null, @@ -82,18 +80,6 @@ return [ */ 'fallback_locale' => 'en', - /* - |-------------------------------------------------------------------------- - | Translation Model Namespace - |-------------------------------------------------------------------------- - | - | Defines the default 'Translation' class namespace. For example, if - | you want to use App\Translations\CountryTranslation instead of App\CountryTranslation - | set this to 'App\Translations'. - | - */ - 'translation_model_namespace' => null, - /* |-------------------------------------------------------------------------- | Translation Suffix diff --git a/config/trustedproxy.php b/config/trustedproxy.php index e242b0da5..acda8d51a 100755 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -15,20 +15,19 @@ return [ * of your proxy (e.g. if using ELB or similar). * */ - 'proxies' => null, // [,], '*', ',' + 'proxies' => null, // [,], '*' /* * To trust one or more specific proxies that connect - * directly to your server, use an array or a string separated by comma of IP addresses: + * directly to your server, use an array of IP addresses: */ - // 'proxies' => ['192.168.1.1'], - // 'proxies' => '192.168.1.1, 192.168.1.2', + # 'proxies' => ['192.168.1.1'], /* * Or, to trust all proxies that connect * directly to your server, use a "*" */ - // 'proxies' => '*', + # 'proxies' => '*', /* * Which headers to use to detect proxy related data (For, Host, Proto, Port) @@ -37,14 +36,10 @@ return [ * * - Illuminate\Http\Request::HEADER_X_FORWARDED_ALL (use all x-forwarded-* headers to establish trust) * - Illuminate\Http\Request::HEADER_FORWARDED (use the FORWARDED header to establish trust) - * - Illuminate\Http\Request::HEADER_X_FORWARDED_AWS_ELB (If you are using AWS Elastic Load Balancer) - * - * - 'HEADER_X_FORWARDED_ALL' (use all x-forwarded-* headers to establish trust) - * - 'HEADER_FORWARDED' (use the FORWARDED header to establish trust) - * - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer) * * @link https://symfony.com/doc/current/deployment/proxies.html */ 'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL, + ]; diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/variations.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/variations.blade.php index 5d6faa7fa..058da4be4 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/variations.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/variations.blade.php @@ -183,7 +183,7 @@ ]; }); - var super_attributes = @json($product->super_attributes()->with('options')->get()); + var super_attributes = @json(app('\Webkul\Product\Repositories\ProductRepository')->getSuperAttributes($product)); var variants = @json($product->variants); Vue.component('variant-form', { diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php index fbec30646..c5cf57152 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php @@ -184,4 +184,30 @@ class AttributeRepository extends Repository return $this->findWhereIn('code', $codes, $attributeColumns); } + + /** + * @return Object + */ + public function getAttributeByCode($code) + { + static $attributes = []; + + if (array_key_exists($code, $attributes)) + return $attributes[$code]; + + return $attributes[$code] = $this->findOneByField('code', $code); + } + + /** + * @return Object + */ + public function getFamilyAttributes($attributeFamily) + { + static $attributes = []; + + if (array_key_exists($attributeFamily->id, $attributes)) + return $attributes[$attributeFamily->id]; + + return $attributes[$attributeFamily->id] = $attributeFamily->custom_attributes; + } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index c2dc10887..d4c333028 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -836,7 +836,8 @@ class Core return $merged; } - public function convertEmptyStringsToNull($array) { + public function convertEmptyStringsToNull($array) + { foreach($array as $key => $value) { if($value == "" || $value == "null") { $array[$key] = null; @@ -845,4 +846,20 @@ class Core return $array; } + + /** + * Create singletom object through single facade + * + * @param string $className + * @return object + */ + public function getSingletonInstance($className) + { + static $instance = []; + + if (array_key_exists($className, $instance)) + return $instance[$className]; + + return $instance[$className] = app($className); + } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Models/Channel.php b/packages/Webkul/Core/src/Models/Channel.php index 11176bc1b..0313d0373 100755 --- a/packages/Webkul/Core/src/Models/Channel.php +++ b/packages/Webkul/Core/src/Models/Channel.php @@ -45,7 +45,7 @@ class Channel extends Model implements ChannelContract } - protected $with = ['base_currency']; + // protected $with = ['base_currency']; /** * Get the base currency diff --git a/packages/Webkul/Product/src/Http/Requests/ProductForm.php b/packages/Webkul/Product/src/Http/Requests/ProductForm.php index b976795ec..e578640f7 100755 --- a/packages/Webkul/Product/src/Http/Requests/ProductForm.php +++ b/packages/Webkul/Product/src/Http/Requests/ProductForm.php @@ -82,8 +82,10 @@ class ProductForm extends FormRequest $attributes = $product->attribute_family->custom_attributes; + $productSuperAttributes = $product->super_attributes; + foreach ($attributes as $attribute) { - if (! $product->super_attributes->contains($attribute)) { + if (! $productSuperAttributes->contains($attribute)) { if ($attribute->code == 'sku') { continue; } @@ -93,6 +95,7 @@ class ProductForm extends FormRequest } $validations = []; + if ($attribute->is_required) { array_push($validations, 'required'); } else { @@ -111,7 +114,7 @@ class ProductForm extends FormRequest array_push($validations, function ($field, $value, $fail) use ($inputs, $attribute) { $column = ProductAttributeValue::$attributeTypeFields[$attribute->type]; - if (!$this->attributeValue->isValueUnique($this->id, $attribute->id, $column, $inputs[$attribute->code])) { + if (! $this->attributeValue->isValueUnique($this->id, $attribute->id, $column, $inputs[$attribute->code])) { $fail('The :attribute has already been taken.'); } }); diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index c339dede8..cba08a127 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -104,16 +104,14 @@ class ProductFlat return false; } - if (Schema::hasTable('product_flat')) { - if (!Schema::hasColumn('product_flat', $attribute->code)) { - Schema::table('product_flat', function (Blueprint $table) use($attribute) { - $table->{$this->attributeTypeFields[$attribute->type]}($attribute->code)->nullable(); + if (! Schema::hasColumn('product_flat', $attribute->code)) { + Schema::table('product_flat', function (Blueprint $table) use($attribute) { + $table->{$this->attributeTypeFields[$attribute->type]}($attribute->code)->nullable(); - if ($attribute->type == 'select' || $attribute->type == 'multiselect') { - $table->string($attribute->code . '_label')->nullable(); - } - }); - } + if ($attribute->type == 'select' || $attribute->type == 'multiselect') { + $table->string($attribute->code . '_label')->nullable(); + } + }); } } @@ -121,16 +119,14 @@ class ProductFlat { $attribute = $this->attributeRepository->find($attributeId); - if (Schema::hasTable('product_flat')) { - if (Schema::hasColumn('product_flat', strtolower($attribute->code))) { - Schema::table('product_flat', function (Blueprint $table) use($attribute) { - $table->dropColumn($attribute->code); + if (Schema::hasColumn('product_flat', strtolower($attribute->code))) { + Schema::table('product_flat', function (Blueprint $table) use($attribute) { + $table->dropColumn($attribute->code); - if ($attribute->type == 'select' || $attribute->type == 'multiselect') { - $table->dropColumn($attribute->code . '_label'); - } - }); - } + if ($attribute->type == 'select' || $attribute->type == 'multiselect') { + $table->dropColumn($attribute->code . '_label'); + } + }); } } @@ -160,6 +156,11 @@ class ProductFlat */ public function createFlat($product, $parentProduct = null) { + static $familyAttributes = []; + + if (! array_key_exists($product->attribute_family->id, $familyAttributes)) + $familyAttributes[$product->attribute_family->id] = $product->attribute_family->custom_attributes; + foreach (core()->getAllChannels() as $channel) { foreach ($channel->locales as $locale) { $productFlat = $this->productFlatRepository->findOneWhere([ @@ -168,7 +169,7 @@ class ProductFlat 'locale' => $locale->code ]); - if (!$productFlat) { + if (! $productFlat) { $productFlat = $this->productFlatRepository->create([ 'product_id' => $product->id, 'channel' => $channel->code, @@ -176,10 +177,16 @@ class ProductFlat ]); } - foreach ($product->attribute_family->custom_attributes as $attribute) { - if (!Schema::hasTable('product_flat') || !Schema::hasColumn('product_flat', $attribute->code)) + foreach ($familyAttributes[$product->attribute_family->id] as $attribute) { + if ($parentProduct && ! in_array($attribute->code, ['sku', 'name', 'price', 'weight', 'status'])) + continue; + + if (in_array($attribute->code, ['short_description', 'tax_category_id', 'meta_title', 'meta_keywords', 'meta_description', 'width', 'height'])) continue; + // if (! Schema::hasColumn('product_flat', $attribute->code)) + // continue; + if ($attribute->value_per_channel) { if ($attribute->value_per_locale) { $productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first(); diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index c29e47110..0a602e951 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -210,7 +210,8 @@ class Product extends Model implements ProductContract if (isset($this->id)) { $this->attributes[$key] = ''; - $attribute = app(\Webkul\Attribute\Repositories\AttributeRepository::class)->findOneByField('code', $key); + $attribute = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class) + ->getAttributeByCode($key); $this->attributes[$key] = $this->getCustomAttributeValue($attribute); @@ -231,7 +232,10 @@ class Product extends Model implements ProductContract $hiddenAttributes = $this->getHidden(); if (isset($this->id)) { - foreach ($this->attribute_family->custom_attributes as $attribute) { + $familyAttributes = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class) + ->getFamilyAttributes($this->attribute_family); + + foreach ($familyAttributes as $attribute) { if (in_array($attribute->code, $hiddenAttributes)) { continue; } @@ -290,7 +294,14 @@ class Product extends Model implements ProductContract */ public function getProductIdAttribute() { - return $image = $this->id; + return $this->id; } + /** + * Return the product attribute. + */ + public function getProductAttribute() + { + return $this; + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Models/ProductAttributeValue.php b/packages/Webkul/Product/src/Models/ProductAttributeValue.php index 58b3c98b0..1ce420902 100755 --- a/packages/Webkul/Product/src/Models/ProductAttributeValue.php +++ b/packages/Webkul/Product/src/Models/ProductAttributeValue.php @@ -11,7 +11,7 @@ class ProductAttributeValue extends Model implements ProductAttributeValueContra { public $timestamps = false; - protected $with = ['attribute']; + // protected $with = ['attribute']; /** * @var array diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 96cac0473..95c9dab43 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -605,4 +605,30 @@ class ProductRepository extends Repository return $results; } + + /** + * Returns product's super attribute with options + * + * @param Product $product + * @return Collection + */ + public function getSuperAttributes($product) + { + $superAttrbutes = []; + + foreach ($product->super_attributes as $key => $attribute) { + $superAttrbutes[$key] = $attribute->toArray(); + + foreach ($attribute->options as $option) { + $superAttrbutes[$key]['options'][] = [ + 'id' => $option->id, + 'admin_name' => $option->admin_name, + 'sort_order' => $option->sort_order, + 'swatch_value' => $option->swatch_value, + ]; + } + } + + return $superAttrbutes; + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/Controllers/HomeController.php b/packages/Webkul/Shop/src/Http/Controllers/HomeController.php index 2fd854e37..e7ae3bbee 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/HomeController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/HomeController.php @@ -5,7 +5,7 @@ namespace Webkul\Shop\Http\Controllers; use Webkul\Shop\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Http\Response; -use Webkul\Core\Repositories\SliderRepository as Sliders; +use Webkul\Core\Repositories\SliderRepository; /** * Home page controller @@ -16,14 +16,16 @@ use Webkul\Core\Repositories\SliderRepository as Sliders; class HomeController extends Controller { protected $_config; - protected $sliders; + + protected $sliderRepository; + protected $current_channel; - public function __construct(Sliders $s) + public function __construct(SliderRepository $sliderRepository) { $this->_config = request('_config'); - $this->sliders = $s; + $this->sliderRepository = $sliderRepository; } /** @@ -34,10 +36,10 @@ use Webkul\Core\Repositories\SliderRepository as Sliders; if (request()->route('any')) abort(404); - $current_channel = core()->getCurrentChannel(); + $currentChannel = core()->getCurrentChannel(); - $all_sliders = $this->sliders->findWhere(['channel_id' => $current_channel['id']]); + $sliderData = $this->sliderRepository->findWhere(['channel_id' => $currentChannel->id])->toArray(); - return view($this->_config['view'])->with('sliderData', $all_sliders->toArray()); + return view($this->_config['view'], compact('sliderData')); } } diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 1580a947d..fb4e1c50f 100755 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -4,7 +4,7 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function //Store front home Route::get('/{any?}', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [ 'view' => 'shop::home.index' - ])->name('shop.home.index'); + ])->where('any', '<>', 'mobile')->name('shop.home.index'); //subscription //subscribe diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php index 1ae9ed8f1..2ad23a66e 100755 --- a/resources/views/vendor/mail/html/message.blade.php +++ b/resources/views/vendor/mail/html/message.blade.php @@ -21,7 +21,7 @@ {{-- Footer --}} @slot('footer') @component('mail::footer') - © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.') + © {{ date('Y') }} {{ config('app.name') }}. All rights reserved. @endcomponent @endslot @endcomponent diff --git a/resources/views/vendor/mail/markdown/message.blade.php b/resources/views/vendor/mail/markdown/message.blade.php index 1ae9ed8f1..b409c71cb 100755 --- a/resources/views/vendor/mail/markdown/message.blade.php +++ b/resources/views/vendor/mail/markdown/message.blade.php @@ -21,7 +21,7 @@ {{-- Footer --}} @slot('footer') @component('mail::footer') - © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.') + © {{ date('Y') }} {{ config('app.name') }}. All rights reserved. @endcomponent @endslot @endcomponent diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php index e2c68be68..fe3889532 100755 --- a/resources/views/vendor/notifications/email.blade.php +++ b/resources/views/vendor/notifications/email.blade.php @@ -56,7 +56,7 @@ 'into your web browser: [:actionURL](:actionURL)', [ 'actionText' => $actionText, - 'actionURL' => $actionUrl, + 'actionURL' => $actionUrl ] ) @endcomponent