diff --git a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php index 1ce888a17..fe923d913 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php @@ -38,8 +38,6 @@ class ConfigurationController extends Controller */ public function __construct(CoreConfigRepository $coreConfigRepository) { - $this->middleware('admin'); - $this->coreConfigRepository = $coreConfigRepository; $this->_config = request('_config'); diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php index 8d5d30f4c..2f85e4f1c 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php @@ -66,8 +66,6 @@ class CustomerController extends Controller ) { $this->_config = request('_config'); - $this->middleware('admin'); - $this->customerRepository = $customerRepository; $this->customerAddressRepository = $customerAddressRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php index 98c44da4c..f3c43802e 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php @@ -32,8 +32,6 @@ class CustomerGroupController extends Controller { $this->_config = request('_config'); - $this->middleware('admin'); - $this->customerGroupRepository = $customerGroupRepository; } diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index 25b2f0d54..7159d4809 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -100,8 +100,6 @@ class DashboardController extends Controller ) { $this->_config = request('_config'); - $this->middleware('admin'); - $this->orderRepository = $orderRepository; $this->orderItemRepository = $orderItemRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php index b238b0b8f..a207ff302 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php @@ -7,16 +7,6 @@ use Webkul\Admin\Exports\DataGridExport; class ExportController extends Controller { - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('admin'); - } - /** * Export datagrid. * diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php index 883e1e894..41939d3bb 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php @@ -47,8 +47,6 @@ class InvoiceController extends Controller OrderRepository $orderRepository, InvoiceRepository $invoiceRepository ) { - $this->middleware('admin'); - $this->_config = request('_config'); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php index e0dc2015a..24b194a65 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php @@ -43,8 +43,6 @@ class OrderController extends Controller OrderCommentRepository $orderCommentRepository ) { - $this->middleware('admin'); - $this->_config = request('_config'); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php index 16a5fec33..6eac08f66 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php @@ -51,8 +51,6 @@ class RefundController extends Controller OrderItemRepository $orderItemRepository, RefundRepository $refundRepository ) { - $this->middleware('admin'); - $this->_config = request('_config'); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php index d468ad326..04dbcae8c 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php @@ -51,8 +51,6 @@ class ShipmentController extends Controller OrderRepository $orderRepository, OrderItemRepository $orderItemRepository ) { - $this->middleware('admin'); - $this->_config = request('_config'); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/TransactionController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/TransactionController.php index 033490ae8..589d6af29 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/TransactionController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/TransactionController.php @@ -52,8 +52,6 @@ class TransactionController extends Controller OrderRepository $orderRepository, OrderTransactionRepository $orderTransactionRepository, InvoiceRepository $invoiceRepository) { - $this->middleware('admin'); - $this->_config = request('_config'); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Admin/src/Routes/notification-routes.php b/packages/Webkul/Admin/src/Routes/notification-routes.php index 767257938..67ff8a515 100644 --- a/packages/Webkul/Admin/src/Routes/notification-routes.php +++ b/packages/Webkul/Admin/src/Routes/notification-routes.php @@ -1,29 +1,22 @@ ['web', 'admin_locale'], 'prefix' => config('app.admin_url')], function () { - // notification - Route::get('notifications', 'Webkul\Notification\Http\Controllers\Admin\NotificationController@index')->defaults('_config', [ +Route::group(['middleware' => ['web', 'admin', 'admin_locale'], 'prefix' => config('app.admin_url')], function () { + Route::get('notifications', [NotificationController::class, 'index'])->defaults('_config', [ 'view' => 'admin::notifications.index', ])->name('admin.notification.index'); - // get notification - Route::get('get-notifications', 'Webkul\Notification\Http\Controllers\Admin\NotificationController@getNotifications') + Route::get('get-notifications', [NotificationController::class, 'getNotifications']) ->name('admin.notification.get-notification'); - //view order - Route::get('viewed-notifications/{orderId}', 'Webkul\Notification\Http\Controllers\Admin\NotificationController@viewedNotifications') + Route::get('viewed-notifications/{orderId}', [NotificationController::class, 'viewedNotifications']) ->name('admin.notification.viewed-notification'); - // read all notification - Route::post('read-all-notifications', 'Webkul\Notification\Http\Controllers\Admin\NotificationController@readAllNotifications') + Route::post('read-all-notifications', [NotificationController::class, 'readAllNotifications']) ->name('admin.notification.read-all'); }); diff --git a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php index c0014c34b..7139c35bf 100644 --- a/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php +++ b/packages/Webkul/CMS/src/Http/Controllers/Admin/PageController.php @@ -30,8 +30,6 @@ class PageController extends Controller */ public function __construct(CmsRepository $cmsRepository) { - $this->middleware('admin'); - $this->cmsRepository = $cmsRepository; $this->_config = request('_config'); diff --git a/packages/Webkul/Customer/src/Http/Controllers/AccountController.php b/packages/Webkul/Customer/src/Http/Controllers/AccountController.php index 2098e2c44..1c8386e19 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/AccountController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/AccountController.php @@ -18,8 +18,6 @@ class AccountController extends Controller */ public function __construct() { - $this->middleware('customer'); - $this->_config = request('_config'); } diff --git a/packages/Webkul/Customer/src/Http/Controllers/AddressController.php b/packages/Webkul/Customer/src/Http/Controllers/AddressController.php index 8ff6d45c4..ac49fcb93 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/AddressController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/AddressController.php @@ -36,8 +36,6 @@ class AddressController extends Controller */ public function __construct(CustomerAddressRepository $customerAddressRepository) { - $this->middleware('customer'); - $this->_config = request('_config'); $this->customer = auth()->guard('customer')->user(); diff --git a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php index 820404da0..61378bc59 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php @@ -54,8 +54,6 @@ class CustomerController extends Controller ProductReviewRepository $productReviewRepository, SubscribersListRepository $subscriptionRepository ) { - $this->middleware('customer'); - $this->_config = request('_config'); $this->customerRepository = $customerRepository; diff --git a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php index 60fbf9b78..2730abb5f 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php @@ -22,8 +22,6 @@ class SessionController extends Controller */ public function __construct() { - $this->middleware('customer')->except(['show', 'create']); - $this->_config = request('_config'); } diff --git a/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php b/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php index c2749e166..85dfcdcaf 100644 --- a/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php +++ b/packages/Webkul/Notification/src/Http/Controllers/Admin/NotificationController.php @@ -8,14 +8,14 @@ use Webkul\Notification\Repositories\NotificationRepository; class NotificationController extends Controller { /** - * Contains route related configuration + * Contains route related configuration. * * @var array */ protected $_config; /** - * NotificationRepository + * Notification repository instance. * * @var object */ @@ -30,8 +30,6 @@ class NotificationController extends Controller { $this->notificationRepository = $notificationRepository; - $this->middleware('admin'); - $this->_config = request('_config'); } @@ -56,7 +54,7 @@ class NotificationController extends Controller if (isset($params['page'])) { unset($params['page']); - } + } if (count($params)) { $searchResults = $this->notificationRepository->getParamsData($params); @@ -71,26 +69,26 @@ class NotificationController extends Controller } /** - * Update the notification is readed or not + * Update the notification is readed or not. * + * @param int $orderId * @return \Illuminate\View\View */ public function viewedNotifications($orderId) { - if ($notification = $this->notificationRepository->where('order_id', $orderId)->first()) { $notification->read = 1; $notification->save(); - return redirect()->route('admin.sales.orders.view',$orderId); - } + return redirect()->route('admin.sales.orders.view', $orderId); + } abort(404); } /** - * Update the notification is readed or not + * Update the notification is readed or not. * * @return array */ @@ -99,8 +97,8 @@ class NotificationController extends Controller $this->notificationRepository->where('read', 0)->update(['read' => 1]); $params = [ - "limit" => 5, - "read" => 0 + 'limit' => 5, + 'read' => 0, ]; $searchResults = $this->notificationRepository->getParamsData($params); @@ -108,9 +106,7 @@ class NotificationController extends Controller return [ 'search_results' => $searchResults, 'total_unread' => $this->notificationRepository->where('read', 0)->count(), - 'success_message' => trans('admin::app.notification.notification-marked-success') + 'success_message' => trans('admin::app.notification.notification-marked-success'), ]; - - abort(404); } } diff --git a/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php b/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php index 0c7c67ddd..a24c4fdf0 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php @@ -25,8 +25,6 @@ class DownloadableProductController extends Controller DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository ) { - $this->middleware('customer'); - $this->downloadableLinkPurchasedRepository = $downloadableLinkPurchasedRepository; parent::__construct(); diff --git a/packages/Webkul/Shop/src/Http/Controllers/OrderController.php b/packages/Webkul/Shop/src/Http/Controllers/OrderController.php index cb8d371f4..9f29a2792 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/OrderController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OrderController.php @@ -43,8 +43,6 @@ class OrderController extends Controller OrderRepository $orderRepository, InvoiceRepository $invoiceRepository ) { - $this->middleware('customer'); - $this->currentCustomer = auth()->guard('customer')->user(); $this->orderRepository = $orderRepository; diff --git a/packages/Webkul/Tax/src/Http/Controllers/TaxController.php b/packages/Webkul/Tax/src/Http/Controllers/TaxController.php index 070269e57..bf7d5cb4b 100755 --- a/packages/Webkul/Tax/src/Http/Controllers/TaxController.php +++ b/packages/Webkul/Tax/src/Http/Controllers/TaxController.php @@ -20,8 +20,6 @@ class TaxController extends Controller */ public function __construct() { - $this->middleware('admin'); - $this->_config = request('_config'); } diff --git a/packages/Webkul/User/src/Http/Controllers/RoleController.php b/packages/Webkul/User/src/Http/Controllers/RoleController.php index 6d1de97df..ae75c1599 100755 --- a/packages/Webkul/User/src/Http/Controllers/RoleController.php +++ b/packages/Webkul/User/src/Http/Controllers/RoleController.php @@ -40,8 +40,6 @@ class RoleController extends Controller RoleRepository $roleRepository, AdminRepository $adminRepository ) { - $this->middleware('admin'); - $this->roleRepository = $roleRepository; $this->adminRepository = $adminRepository; diff --git a/packages/Webkul/User/src/Http/Controllers/SessionController.php b/packages/Webkul/User/src/Http/Controllers/SessionController.php index 2cef60095..4182da59b 100755 --- a/packages/Webkul/User/src/Http/Controllers/SessionController.php +++ b/packages/Webkul/User/src/Http/Controllers/SessionController.php @@ -18,8 +18,6 @@ class SessionController extends Controller */ public function __construct() { - $this->middleware('admin')->except(['create', 'store']); - $this->_config = request('_config'); } diff --git a/packages/Webkul/User/src/Http/Controllers/UserController.php b/packages/Webkul/User/src/Http/Controllers/UserController.php index b6d5e1af0..faa59b435 100755 --- a/packages/Webkul/User/src/Http/Controllers/UserController.php +++ b/packages/Webkul/User/src/Http/Controllers/UserController.php @@ -49,8 +49,6 @@ class UserController extends Controller $this->roleRepository = $roleRepository; $this->_config = request('_config'); - - $this->middleware('guest', ['except' => 'destroy']); } /**