From c7e0a9723eff7e7e7edf3da740710eb7d087ae1a Mon Sep 17 00:00:00 2001 From: howdu Date: Tue, 27 Oct 2020 07:56:41 +0000 Subject: [PATCH 1/2] Fix error with misisng locale Fixed this error and searhc for other files with same code. Trying to get property 'direction' of non-object (View: /packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php) --- .../src/Resources/views/layouts/anonymous-master.blade.php | 2 +- .../Webkul/Shop/src/Resources/views/layouts/master.blade.php | 4 ++-- .../src/Resources/views/shop/layouts/master.blade.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php b/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php index 411484cc2..930e7760e 100755 --- a/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/layouts/anonymous-master.blade.php @@ -71,7 +71,7 @@ {!! view_render_event('bagisto.admin.layout.head') !!} - getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;"> + getCurrentLocale() && core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;">
diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php index 6ffa5ec62..83f6c798b 100755 --- a/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/master.blade.php @@ -39,7 +39,7 @@ -getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;"> +getCurrentLocale() && core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif style="scroll-behavior: smooth;"> {!! view_render_event('bagisto.shop.layout.body.before') !!} @@ -103,7 +103,7 @@ @endif window.serverErrors = []; - + @if (isset($errors)) @if (count($errors)) window.serverErrors = @json($errors->getMessages()); diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/layouts/master.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/layouts/master.blade.php index 5c0b95c04..3d6c74e2d 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/layouts/master.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/layouts/master.blade.php @@ -20,7 +20,7 @@ - @if (core()->getCurrentLocale()->direction == 'rtl') + @if (core()->getCurrentLocale() && core()->getCurrentLocale()->direction == 'rtl') @endif @@ -45,7 +45,7 @@ - getCurrentLocale()->direction == 'rtl') class="rtl" @endif> + getCurrentLocale() && core()->getCurrentLocale()->direction == 'rtl') class="rtl" @endif> {!! view_render_event('bagisto.shop.layout.body.before') !!} @include('shop::UI.particals') From 1bc9e90ac6ed28359c43a33717549e284945b06e Mon Sep 17 00:00:00 2001 From: howdu Date: Tue, 27 Oct 2020 09:53:00 +0000 Subject: [PATCH 2/2] Prevent errors when running route:list Trying to access array offset on value of type null In ResourceController.php line 48 --- .../Controllers/Shop/InvoiceController.php | 4 +++- .../Controllers/Shop/ResourceController.php | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/Webkul/API/Http/Controllers/Shop/InvoiceController.php b/packages/Webkul/API/Http/Controllers/Shop/InvoiceController.php index d20a9fffb..4efcb0a19 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/InvoiceController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/InvoiceController.php @@ -43,7 +43,9 @@ class InvoiceController extends Controller $this->middleware('auth:' . $this->guard); } - $this->repository = app($this->_config['repository']); + if ($this->_config) { + $this->repository = app($this->_config['repository']); + } } /** diff --git a/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php b/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php index e4861136d..1bc627003 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php @@ -12,7 +12,7 @@ class ResourceController extends Controller * @var array */ protected $guard; - + /** * Contains route related configuration * @@ -45,7 +45,9 @@ class ResourceController extends Controller $this->middleware('auth:' . $this->guard); } - $this->repository = app($this->_config['repository']); + if ($this->_config) { + $this->repository = app($this->_config['repository']); + } } /** @@ -58,8 +60,8 @@ class ResourceController extends Controller $query = $this->repository->scopeQuery(function($query) { if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) { $query = $query->where('customer_id', auth()->user()->id ); - } - + } + foreach (request()->except(['page', 'limit', 'pagination', 'sort', 'order', 'token']) as $input => $value) { $query = $query->whereIn($input, array_map('trim', explode(',', $value))); } @@ -89,11 +91,11 @@ class ResourceController extends Controller * @return \Illuminate\Http\Response */ public function get($id) - { - $query = isset($this->_config['authorization_required']) && $this->_config['authorization_required'] ? - $this->repository->where('customer_id', auth()->user()->id)->findOrFail($id) : + { + $query = isset($this->_config['authorization_required']) && $this->_config['authorization_required'] ? + $this->repository->where('customer_id', auth()->user()->id)->findOrFail($id) : $this->repository->findOrFail($id); - + return new $this->_config['resource']($query); } @@ -108,7 +110,7 @@ class ResourceController extends Controller $wishlistProduct = $this->repository->findOrFail($id); $this->repository->delete($id); - + return response()->json([ 'message' => 'Item removed successfully.', ]);