From 0d05af1ad7d454b3a9a1f9c2e227e9a151eced15 Mon Sep 17 00:00:00 2001 From: Shivendra Date: Mon, 22 Jul 2024 15:46:41 +0530 Subject: [PATCH 1/6] Fix settings route namespacing and fix group page --- .../AttributeController.php | 2 +- .../EmailTemplateController.php | 2 +- .../{Setting => Settings}/GroupController.php | 65 ++++++++----------- .../LocationController.php | 2 +- .../PipelineController.php | 2 +- .../{Setting => Settings}/RoleController.php | 2 +- .../SettingController.php | 2 +- .../SourceController.php | 2 +- .../{Setting => Settings}/TagController.php | 2 +- .../{Setting => Settings}/TypeController.php | 2 +- .../{Setting => Settings}/UserController.php | 2 +- .../WarehouseController.php | 2 +- .../WorkflowController.php | 2 +- packages/Webkul/Admin/src/Http/routes.php | 17 +---- .../Admin/src/Resources/lang/en/app.php | 9 ++- .../views/settings/groups/index.blade.php | 22 +++++-- .../views/settings/types/index.blade.php | 16 +++-- .../Admin/src/Routes/settings-routes.php | 20 +++++- 18 files changed, 91 insertions(+), 82 deletions(-) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/AttributeController.php (99%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/EmailTemplateController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/GroupController.php (59%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/LocationController.php (97%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/PipelineController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/RoleController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/SettingController.php (85%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/SourceController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/TagController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/TypeController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/UserController.php (99%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/WarehouseController.php (98%) rename packages/Webkul/Admin/src/Http/Controllers/{Setting => Settings}/WorkflowController.php (98%) diff --git a/packages/Webkul/Admin/src/Http/Controllers/Setting/AttributeController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/AttributeController.php similarity index 99% rename from packages/Webkul/Admin/src/Http/Controllers/Setting/AttributeController.php rename to packages/Webkul/Admin/src/Http/Controllers/Settings/AttributeController.php index e6b6e551f..b58373a64 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Setting/AttributeController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/AttributeController.php @@ -1,6 +1,6 @@ ajax()) { - return app(\Webkul\Admin\DataGrids\Setting\GroupDataGrid::class)->toJson(); + return datagrid(GroupDataGrid::class)->process(); } return view('admin::settings.groups.index'); } - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\View\View - */ - public function create() - { - return view('admin::settings.groups.create'); - } - /** * Store a newly created resource in storage. */ - public function store(): JsonResource + public function store(): JsonResponse { $this->validate(request(), [ 'name' => 'required|unique:groups,name', @@ -51,12 +42,16 @@ public function store(): JsonResource Event::dispatch('settings.group.create.before'); - $group = $this->groupRepository->create(request()->all()); + $group = $this->groupRepository->create(request()->only([ + 'name', + 'description', + ])); Event::dispatch('settings.group.create.after', $group); - return new JsonResource([ - 'data' => $group, + return new JsonResponse([ + 'data' => $group, + 'message' => trans('admin::app.settings.groups.index.create-success'), ]); } @@ -74,11 +69,8 @@ public function edit(int $id): JsonResource /** * Update the specified resource in storage. - * - * @param int $id - * @return \Illuminate\Http\Response */ - public function update($id) + public function update(int $id): JsonResponse { $this->validate(request(), [ 'name' => 'required|unique:groups,name,'.$id, @@ -86,43 +78,42 @@ public function update($id) Event::dispatch('settings.group.update.before', $id); - $group = $this->groupRepository->update(request()->all(), $id); + $group = $this->groupRepository->update(request()->only([ + 'name', + 'description', + ]), $id); Event::dispatch('settings.group.update.after', $group); - return new JsonResource([ - 'data' => $group, + return new JsonResponse([ + 'data' => $group, + 'message' => trans('admin::app.settings.groups.index.update-success'), ]); } /** * Remove the specified resource from storage. * - * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(int $id): JsonResponse { $group = $this->groupRepository->findOrFail($id); try { Event::dispatch('settings.group.delete.before', $id); - $this->groupRepository->delete($id); + $group->delete($id); Event::dispatch('settings.group.delete.after', $id); - return response()->json([ - 'message' => trans('admin::app.settings.groups.destroy-success'), + return new JsonResponse([ + 'message' => trans('admin::app.settings.groups.index.destroy-success'), ], 200); } catch (\Exception $exception) { - return response()->json([ - 'message' => trans('admin::app.settings.groups.delete-failed'), + return new JsonResponse([ + 'message' => trans('admin::app.settings.groups.index.delete-failed'), ], 400); } - - return response()->json([ - 'message' => trans('admin::app.settings.groups.delete-failed'), - ], 400); } } diff --git a/packages/Webkul/Admin/src/Http/Controllers/Setting/LocationController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/LocationController.php similarity index 97% rename from packages/Webkul/Admin/src/Http/Controllers/Setting/LocationController.php rename to packages/Webkul/Admin/src/Http/Controllers/Settings/LocationController.php index 8adda2cbe..a63e6173f 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Setting/LocationController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/LocationController.php @@ -1,6 +1,6 @@ 'settings', - 'namespace' => 'Webkul\Admin\Http\Controllers\Setting', + 'namespace' => 'Webkul\Admin\Http\Controllers\Settings', ], function () { Route::get('', 'SettingController@index')->name('admin.settings.index'); - // Groups Routes - Route::prefix('groups')->group(function () { - Route::get('', 'GroupController@index')->name('admin.settings.groups.index'); - - Route::get('create', 'GroupController@create')->name('admin.settings.groups.create'); - - Route::post('create', 'GroupController@store')->name('admin.settings.groups.store'); - - Route::get('edit/{id}', 'GroupController@edit')->name('admin.settings.groups.edit'); - - Route::put('edit/{id}', 'GroupController@update')->name('admin.settings.groups.update'); - - Route::delete('{id}', 'GroupController@destroy')->name('admin.settings.groups.delete'); - }); - // Roles Routes Route::prefix('roles')->group(function () { Route::get('', 'RoleController@index')->name('admin.settings.roles.index'); diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 676b856c2..6c26e0c9c 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -137,8 +137,13 @@ 'settings' => [ 'groups' => [ 'index' => [ - 'create-btn' => 'Create Group', - 'title' => 'Groups', + 'create-btn' => 'Create Group', + 'title' => 'Groups', + 'create-success' => 'Group created successfully.', + 'update-success' => 'Group updated successfully.', + 'destroy-success' => 'Group deleted successfully.', + 'delete-failed' => 'Group can not be deleted.', + 'datagrid' => [ 'delete' => 'Delete', 'description' => 'Description', diff --git a/packages/Webkul/Admin/src/Resources/views/settings/groups/index.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/groups/index.blade.php index 4d047ef8d..1b5178b2e 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/groups/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/groups/index.blade.php @@ -7,6 +7,7 @@
+
@@ -40,6 +41,7 @@ class="primary-button"
+
@@ -51,7 +53,7 @@ class="primary-button"
- {!! view_render_event('krayin.admin.settings.groups.index.create-button.before') !!} + {!! view_render_event('krayin.admin.settings.groups.index.create_button.before') !!} - {!! view_render_event('krayin.admin.settings.groups.index.create-button.after') !!} + {!! view_render_event('krayin.admin.settings.groups.index.create_button.after') !!}
{!! view_render_event('krayin.admin.settings.groups.index.datagrid.before') !!} +
- {!! view_render_event('krayin.admin.settings.groups.create_form_controls.before') !!} + {!! view_render_event('krayin.admin.settings.groups.index.create_form_controls.before') !!} @@ -143,13 +146,14 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 - {!! view_render_event('krayin.admin.settings.groups.create.before') !!} + {!! view_render_event('krayin.admin.settings.groups.index.content.before') !!} + @lang('admin::app.settings.groups.index.create.name') @@ -167,6 +171,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 + @lang('admin::app.settings.groups.index.create.description') @@ -184,11 +189,12 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 - {!! view_render_event('krayin.admin.settings.groups.create.after') !!} + {!! view_render_event('krayin.admin.settings.groups.index.content.after') !!} + - {!! view_render_event('krayin.admin.settings.groups.create_form_controls.after') !!} + {!! view_render_event('krayin.admin.settings.groups.index.create_form_controls.after') !!}
@@ -248,6 +254,8 @@ class="primary-button justify-center" this.$refs.groupUpdateAndCreateModal.toggle(); + this.$emitter.emit('add-flash', { type: 'success', message: response.data.message }); + this.$refs.datagrid.get(); resetForm(); diff --git a/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php index 6d8283f1a..43363be55 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php @@ -53,7 +53,7 @@ class="primary-button"
- {!! view_render_event('krayin.admin.settings.types.index.create-button.before') !!} + {!! view_render_event('krayin.admin.settings.types.index.create_button.before') !!} - {!! view_render_event('krayin.admin.settings.types.index.create-button.after') !!} + {!! view_render_event('krayin.admin.settings.types.index.create_button.after') !!}
@@ -122,7 +122,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 - {!! view_render_event('krayin.admin.settings.groups.index.datagrid.after') !!} + {!! view_render_event('krayin.admin.settings.types.index.datagrid.after') !!}
- {!! view_render_event('krayin.admin.settings.groups.create_form_controls.before') !!} + {!! view_render_event('krayin.admin.settings.types.index.create_form_controls.before') !!} @@ -146,13 +146,14 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 - {!! view_render_event('krayin.admin.settings.types.content.before') !!} + {!! view_render_event('krayin.admin.settings.types.index.content.before') !!} + @lang('admin::app.settings.types.index.create.name') @@ -170,11 +171,12 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 - {!! view_render_event('krayin.admin.settings.types.content.after') !!} + {!! view_render_event('krayin.admin.settings.types.index.content.after') !!} + - {!! view_render_event('krayin.admin.settings.groups.create_form_controls.after') !!} + {!! view_render_event('krayin.admin.settings.types.index.create_form_controls.after') !!}
diff --git a/packages/Webkul/Admin/src/Routes/settings-routes.php b/packages/Webkul/Admin/src/Routes/settings-routes.php index a0665951c..f1425c581 100644 --- a/packages/Webkul/Admin/src/Routes/settings-routes.php +++ b/packages/Webkul/Admin/src/Routes/settings-routes.php @@ -1,13 +1,31 @@ ['admin_locale'], 'prefix' => config('app.admin_path')], function () { Route::prefix('settings')->group(function () { + /** + * Groups routes. + */ + Route::controller(GroupController::class)->prefix('groups')->group(function () { + Route::get('', 'index')->name('admin.settings.groups.index'); + + Route::get('create', 'create')->name('admin.settings.groups.create'); + + Route::post('create', 'store')->name('admin.settings.groups.store'); + + Route::get('edit/{id}', 'edit')->name('admin.settings.groups.edit'); + + Route::put('edit/{id}', 'update')->name('admin.settings.groups.update'); + + Route::delete('{id}', 'destroy')->name('admin.settings.groups.delete'); + }); + /** * Type routes. */ From d96290d25621016cd536a4a0749799af8530c7a2 Mon Sep 17 00:00:00 2001 From: Shivendra Date: Mon, 22 Jul 2024 17:30:58 +0530 Subject: [PATCH 2/6] fixed roles page routes --- .../Controllers/Settings/GroupController.php | 4 +- .../Controllers/Settings/RoleController.php | 74 ++++++++++--------- packages/Webkul/Admin/src/Http/routes.php | 16 ---- .../src/Providers/AdminServiceProvider.php | 2 +- .../Admin/src/Resources/lang/en/app.php | 16 +++- .../views/settings/roles/create.blade.php | 21 +++--- .../views/settings/roles/edit.blade.php | 19 ++--- .../views/settings/roles/index.blade.php | 14 ++-- .../Admin/src/Routes/settings-routes.php | 20 ++++- packages/Webkul/Admin/src/Routes/web.php | 1 - 10 files changed, 96 insertions(+), 91 deletions(-) diff --git a/packages/Webkul/Admin/src/Http/Controllers/Settings/GroupController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/GroupController.php index c2deaa4ac..9f568d241 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Settings/GroupController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/GroupController.php @@ -3,12 +3,12 @@ namespace Webkul\Admin\Http\Controllers\Settings; use Illuminate\Http\JsonResponse; -use Illuminate\View\View; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Event; +use Illuminate\View\View; +use Webkul\Admin\DataGrids\Setting\GroupDataGrid; use Webkul\Admin\Http\Controllers\Controller; use Webkul\User\Repositories\GroupRepository; -use Webkul\Admin\DataGrids\Setting\GroupDataGrid; class GroupController extends Controller { diff --git a/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php b/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php index a647939ba..fd7e7dd2d 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Settings/RoleController.php @@ -2,12 +2,13 @@ namespace Webkul\Admin\Http\Controllers\Settings; +use Illuminate\View\View; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Event; -use Illuminate\View\View; -use Webkul\Admin\DataGrids\Setting\RoleDataGrid; -use Webkul\Admin\Http\Controllers\Controller; use Webkul\User\Repositories\RoleRepository; +use Webkul\User\Repositories\UserRepository; +use Webkul\Admin\Http\Controllers\Controller; +use Webkul\Admin\DataGrids\Setting\RoleDataGrid; class RoleController extends Controller { @@ -16,12 +17,13 @@ class RoleController extends Controller * * @return void */ - public function __construct(protected RoleRepository $roleRepository) {} - + public function __construct( + protected RoleRepository $roleRepository, + protected UserRepository $userRepository + ) {} + /** * Display a listing of the resource. - * - * @return \Illuminate\View\View */ public function index(): View|JsonResponse { @@ -52,34 +54,37 @@ public function store() $this->validate(request(), [ 'name' => 'required', 'permission_type' => 'required', + 'description' => 'required', ]); Event::dispatch('settings.role.create.before'); - $roleData = request()->all(); + $data = request()->only([ + 'name', + 'description', + 'permission_type', + 'permissions', + ]); - if ($roleData['permission_type'] == 'custom') { - if (! isset($roleData['permissions'])) { - $roleData['permissions'] = []; + if ($data['permission_type'] == 'custom') { + if (! isset($data['permissions'])) { + $data['permissions'] = []; } } - $role = $this->roleRepository->create($roleData); + $role = $this->roleRepository->create($data); Event::dispatch('settings.role.create.after', $role); - session()->flash('success', trans('admin::app.settings.roles.create-success')); + session()->flash('success', trans('admin::app.settings.roles.index.create-success')); return redirect()->route('admin.settings.roles.index'); } /** * Show the form for editing the specified resource. - * - * @param int $id - * @return \Illuminate\View\View */ - public function edit($id) + public function edit(int $id): View { $role = $this->roleRepository->findOrFail($id); @@ -89,31 +94,31 @@ public function edit($id) /** * Update the specified resource in storage. * - * @param int $id * @return \Illuminate\Http\Response */ - public function update($id) + public function update(int $id) { $this->validate(request(), [ 'name' => 'required', - 'permission_type' => 'required', + 'permission_type' => 'required|in:all,custom', + 'description' => 'required', ]); Event::dispatch('settings.role.update.before', $id); - $roleData = request()->all(); - - if ($roleData['permission_type'] == 'custom') { - if (! isset($roleData['permissions'])) { - $roleData['permissions'] = []; - } - } + $data = array_merge(request()->only([ + 'name', + 'description', + 'permission_type', + ]), [ + 'permissions' => request()->has('permissions') ? request('permissions') : [], + ]); - $role = $this->roleRepository->update($roleData, $id); + $role = $this->roleRepository->update($data, $id); Event::dispatch('settings.role.update.after', $role); - session()->flash('success', trans('admin::app.settings.roles.update-success')); + session()->flash('success', trans('admin::app.settings.roles.index.update-success')); return redirect()->route('admin.settings.roles.index'); } @@ -121,10 +126,9 @@ public function update($id) /** * Remove the specified resource from storage. * - * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(int $id) { $response = [ 'responseCode' => 400, @@ -133,11 +137,11 @@ public function destroy($id) $role = $this->roleRepository->findOrFail($id); if ($role->admins && $role->admins->count() >= 1) { - $response['message'] = trans('admin::app.settings.roles.being-used'); + $response['message'] = trans('admin::app.settings.roles.index.being-used'); session()->flash('error', $response['message']); } elseif ($this->roleRepository->count() == 1) { - $response['message'] = trans('admin::app.settings.roles.last-delete-error'); + $response['message'] = trans('admin::app.settings.roles.index.last-delete-error'); session()->flash('error', $response['message']); } else { @@ -145,13 +149,13 @@ public function destroy($id) Event::dispatch('settings.role.delete.before', $id); if (auth()->guard('user')->user()->role_id == $id) { - $response['message'] = trans('admin::app.settings.roles.current-role-delete-error'); + $response['message'] = trans('admin::app.settings.roles.index.current-role-delete-error'); } else { $this->roleRepository->delete($id); Event::dispatch('settings.role.delete.after', $id); - $message = trans('admin::app.settings.roles.delete-success'); + $message = trans('admin::app.settings.roles.index.delete-success'); $response = [ 'responseCode' => 200, diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index a35c1e453..b628e4a47 100644 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -250,21 +250,6 @@ Route::get('', 'SettingController@index')->name('admin.settings.index'); - // Roles Routes - Route::prefix('roles')->group(function () { - Route::get('', 'RoleController@index')->name('admin.settings.roles.index'); - - Route::get('create', 'RoleController@create')->name('admin.settings.roles.create'); - - Route::post('create', 'RoleController@store')->name('admin.settings.roles.store'); - - Route::get('edit/{id}', 'RoleController@edit')->name('admin.settings.roles.edit'); - - Route::put('edit/{id}', 'RoleController@update')->name('admin.settings.roles.update'); - - Route::delete('{id}', 'RoleController@destroy')->name('admin.settings.roles.delete'); - }); - // Users Routes Route::prefix('users')->group(function () { Route::get('', 'UserController@index')->name('admin.settings.users.index'); @@ -337,7 +322,6 @@ Route::delete('{id}', 'SourceController@destroy')->name('admin.settings.sources.delete'); }); - // Email Templates Routes Route::prefix('email-templates')->group(function () { Route::get('', 'EmailTemplateController@index')->name('admin.settings.email_templates.index'); diff --git a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php index 9d2f37768..4634f5084 100644 --- a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php @@ -6,9 +6,9 @@ use Illuminate\Foundation\AliasLoader; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Blade; +use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Webkul\Admin\Http\Middleware\Locale; -use Illuminate\Support\Facades\Route; class AdminServiceProvider extends ServiceProvider { diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 6c26e0c9c..5513e0c76 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -119,6 +119,7 @@ 'index' => [ 'title' => 'Products', 'create-btn' => 'Create Product', + 'datagrid' => [ 'allocated' => 'Allocated', 'delete' => 'Delete', @@ -167,9 +168,18 @@ 'roles' => [ 'index' => [ - 'create-btn' => 'Create Roles', - 'title' => 'Roles', - 'settings' => 'Settings', + 'being-used' => 'Role can not be deleted, as this is being used in admin user.', + 'create-btn' => 'Create Roles', + 'create-success' => 'Role created successfully.', + 'current-role-delete-error' => 'Can not delete role assigned to the current user.', + 'delete-failed' => 'Role can not be deleted.', + 'delete-success' => 'Role deleted successfully.', + 'last-delete-error' => 'At least one role is required.', + 'settings' => 'Settings', + 'title' => 'Roles', + 'update-success' => 'Role updated successfully.', + 'user-define-error' => 'Can not delete system role.', + 'datagrid' => [ 'all' => 'All', 'custom' => 'Custom', diff --git a/packages/Webkul/Admin/src/Resources/views/settings/roles/create.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/roles/create.blade.php index e520eeb4f..2addc18cc 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/roles/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/roles/create.blade.php @@ -4,11 +4,12 @@ @lang('admin::app.settings.roles.create.title') - {!! view_render_event('krayin.settings.roles.create.before') !!} + {!! view_render_event('krayin.admin.settings.roles.create.before') !!} + - {!! view_render_event('krayin.settings.roles.create.create_form_controls.before') !!} + {!! view_render_event('krayin.admin.settings.roles.create.form_controls.before') !!}

@@ -38,8 +39,7 @@ class="primary-button"

- - {!! view_render_event('krayin.settings.roles.create.card.access_control.before') !!} + {!! view_render_event('krayin.admin.settings.roles.create.card.access_control.before') !!}
@@ -57,14 +57,13 @@ class="primary-button"
- {!! view_render_event('krayin.settings.roles.create.card.access_control.after') !!} - + {!! view_render_event('krayin.admin.settings.roles.create.card.access_control.after') !!}
- {!! view_render_event('krayin.settings.roles.create.card.accordion.general.before') !!} + {!! view_render_event('krayin.admin.settings.roles.create.card.accordion.general.before') !!} @@ -116,16 +115,14 @@ class="primary-button" - {!! view_render_event('krayin.settings.roles.create.card.accordion.general.after') !!} - + {!! view_render_event('krayin.admin.settings.roles.create.card.accordion.general.after') !!}
- {!! view_render_event('krayin.settings.roles.create.create_form_controls.after') !!} - + {!! view_render_event('krayin.admin.settings.roles.create.create_form_controls.after') !!} - {!! view_render_event('krayin.settings.roles.create.after') !!} + {!! view_render_event('krayin.admin.settings.roles.create.after') !!} @pushOnce('scripts') - + + @endPushOnce + diff --git a/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php index 43363be55..391287758 100644 --- a/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/settings/types/index.blade.php @@ -19,12 +19,12 @@
@@ -130,7 +130,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200 ref="modalForm" >
- {!! view_render_event('krayin.admin.settings.types.index.create_form_controls.before') !!} + {!! view_render_event('krayin.admin.settings.types.index.form_controls.before') !!} @@ -187,7 +187,7 @@ class="primary-button justify-center" - {!! view_render_event('krayin.admin.settings.types.index.create_form_controls.after') !!} + {!! view_render_event('krayin.admin.settings.types.index.form_controls.after') !!}
From 2e4322ca726e142dc5a65d42c81d7932d7270de8 Mon Sep 17 00:00:00 2001 From: Shivendra Date: Tue, 23 Jul 2024 17:50:37 +0530 Subject: [PATCH 6/6] Refactor cantacts and products routes --- .../src/DataGrids/Product/ProductDataGrid.php | 3 + packages/Webkul/Admin/src/Http/routes.php | 70 ------------------- .../Admin/src/Routes/contacts-routes.php | 52 ++++++++++++++ .../Admin/src/Routes/products-routes.php | 36 ++++++++++ .../Admin/src/Routes/settings-routes.php | 18 ++++- packages/Webkul/Admin/src/Routes/web.php | 10 +++ 6 files changed, 117 insertions(+), 72 deletions(-) create mode 100644 packages/Webkul/Admin/src/Routes/contacts-routes.php create mode 100644 packages/Webkul/Admin/src/Routes/products-routes.php diff --git a/packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php index 21f4180a4..11e88c889 100644 --- a/packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php @@ -95,6 +95,7 @@ public function prepareColumns(): void public function prepareActions(): void { $this->addAction([ + 'index' => 'view', 'icon' => 'icon-dark', 'title' => trans('admin::app.products.index.datagrid.view'), 'method' => 'GET', @@ -104,6 +105,7 @@ public function prepareActions(): void ]); $this->addAction([ + 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.products.index.datagrid.edit'), 'method' => 'GET', @@ -113,6 +115,7 @@ public function prepareActions(): void ]); $this->addAction([ + 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.products.index.datagrid.delete'), 'method' => 'DELETE', diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index b628e4a47..c6144a060 100644 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -172,76 +172,6 @@ Route::put('mass-destroy', 'EmailController@massDestroy')->name('admin.mail.mass_delete'); }); - // Contacts Routes - Route::group([ - 'prefix' => 'contacts', - 'namespace' => 'Webkul\Admin\Http\Controllers\Contact', - ], function () { - // Customers Routes - Route::prefix('persons')->group(function () { - Route::get('', 'PersonController@index')->name('admin.contacts.persons.index'); - - Route::get('create', 'PersonController@create')->name('admin.contacts.persons.create'); - - Route::post('create', 'PersonController@store')->name('admin.contacts.persons.store'); - - Route::get('edit/{id?}', 'PersonController@edit')->name('admin.contacts.persons.edit'); - - Route::put('edit/{id}', 'PersonController@update')->name('admin.contacts.persons.update'); - - Route::get('search', 'PersonController@search')->name('admin.contacts.persons.search'); - - Route::middleware(['throttle:100,60'])->delete('{id}', 'PersonController@destroy')->name('admin.contacts.persons.delete'); - - Route::post('mass-destroy', 'PersonController@massDestroy')->name('admin.contacts.persons.mass_delete'); - }); - - // Companies Routes - Route::prefix('organizations')->group(function () { - Route::get('', 'OrganizationController@index')->name('admin.contacts.organizations.index'); - - Route::get('create', 'OrganizationController@create')->name('admin.contacts.organizations.create'); - - Route::post('create', 'OrganizationController@store')->name('admin.contacts.organizations.store'); - - Route::get('edit/{id?}', 'OrganizationController@edit')->name('admin.contacts.organizations.edit'); - - Route::put('edit/{id}', 'OrganizationController@update')->name('admin.contacts.organizations.update'); - - Route::delete('{id}', 'OrganizationController@destroy')->name('admin.contacts.organizations.delete'); - - Route::put('mass-destroy', 'OrganizationController@massDestroy')->name('admin.contacts.organizations.mass_delete'); - }); - }); - - // Products Routes - Route::group([ - 'prefix' => 'products', - 'namespace' => 'Webkul\Admin\Http\Controllers\Product', - ], function () { - Route::get('', 'ProductController@index')->name('admin.products.index'); - - Route::get('create', 'ProductController@create')->name('admin.products.create'); - - Route::post('create', 'ProductController@store')->name('admin.products.store'); - - Route::get('view/{id}', 'ProductController@view')->name('admin.products.view'); - - Route::get('edit/{id}', 'ProductController@edit')->name('admin.products.edit'); - - Route::put('edit/{id}', 'ProductController@update')->name('admin.products.update'); - - Route::get('search', 'ProductController@search')->name('admin.products.search'); - - Route::get('{id}/warehouses', 'ProductController@warehouses')->name('admin.products.warehouses'); - - Route::post('{id}/inventories/{warehouseId?}', 'ProductController@storeInventories')->name('admin.products.inventories.store'); - - Route::delete('{id}', 'ProductController@destroy')->name('admin.products.delete'); - - Route::put('mass-destroy', 'ProductController@massDestroy')->name('admin.products.mass_delete'); - }); - // Contacts Routes Route::group([ 'prefix' => 'settings', diff --git a/packages/Webkul/Admin/src/Routes/contacts-routes.php b/packages/Webkul/Admin/src/Routes/contacts-routes.php new file mode 100644 index 000000000..8c96bbe4e --- /dev/null +++ b/packages/Webkul/Admin/src/Routes/contacts-routes.php @@ -0,0 +1,52 @@ + ['admin_locale'], 'prefix' => config('app.admin_path')], function () { + Route::prefix('contacts')->group(function () { + /** + * Persons routes. + */ + Route::controller(PersonController::class)->prefix('persons')->group(function () { + Route::get('', 'index')->name('admin.contacts.persons.index'); + + Route::get('create', 'create')->name('admin.contacts.persons.create'); + + Route::post('create', 'store')->name('admin.contacts.persons.store'); + + Route::get('edit/{id?}', 'edit')->name('admin.contacts.persons.edit'); + + Route::put('edit/{id}', 'update')->name('admin.contacts.persons.update'); + + Route::get('search', 'search')->name('admin.contacts.persons.search'); + + Route::middleware(['throttle:100,60'])->delete('{id}', 'destroy')->name('admin.contacts.persons.delete'); + + Route::post('mass-destroy', 'massDestroy')->name('admin.contacts.persons.mass_delete'); + }); + + /** + * Organization routes. + */ + Route::controller(OrganizationController::class)->prefix('organizations')->group(function () { + Route::get('', 'index')->name('admin.contacts.organizations.index'); + + Route::get('create', 'create')->name('admin.contacts.organizations.create'); + + Route::post('create', 'store')->name('admin.contacts.organizations.store'); + + Route::get('edit/{id?}', 'edit')->name('admin.contacts.organizations.edit'); + + Route::put('edit/{id}', 'update')->name('admin.contacts.organizations.update'); + + Route::delete('{id}', 'destroy')->name('admin.contacts.organizations.delete'); + + Route::put('mass-destroy', 'massDestroy')->name('admin.contacts.organizations.mass_delete'); + }); + }); +}); diff --git a/packages/Webkul/Admin/src/Routes/products-routes.php b/packages/Webkul/Admin/src/Routes/products-routes.php new file mode 100644 index 000000000..caa7fb580 --- /dev/null +++ b/packages/Webkul/Admin/src/Routes/products-routes.php @@ -0,0 +1,36 @@ + ['admin_locale'], 'prefix' => config('app.admin_path')], function () { + /** + * Products routes. + */ + Route::controller(ProductController::class)->prefix('products')->group(function () { + Route::get('', 'index')->name('admin.products.index'); + + Route::get('create', 'create')->name('admin.products.create'); + + Route::post('create', 'store')->name('admin.products.store'); + + Route::get('view/{id}', 'view')->name('admin.products.view'); + + Route::get('edit/{id}', 'edit')->name('admin.products.edit'); + + Route::put('edit/{id}', 'update')->name('admin.products.update'); + + Route::get('search', 'search')->name('admin.products.search'); + + Route::get('{id}/warehouses', 'warehouses')->name('admin.products.warehouses'); + + Route::post('{id}/inventories/{warehouseId?}', 'storeInventories')->name('admin.products.inventories.store'); + + Route::delete('{id}', 'destroy')->name('admin.products.delete'); + + Route::post('mass-destroy', 'massDestroy')->name('admin.products.mass_delete'); + }); +}); diff --git a/packages/Webkul/Admin/src/Routes/settings-routes.php b/packages/Webkul/Admin/src/Routes/settings-routes.php index f49ecac21..fa80ebf85 100644 --- a/packages/Webkul/Admin/src/Routes/settings-routes.php +++ b/packages/Webkul/Admin/src/Routes/settings-routes.php @@ -3,6 +3,7 @@ use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Settings\GroupController; use Webkul\Admin\Http\Controllers\Settings\RoleController; +use Webkul\Admin\Http\Controllers\Settings\SourceController; use Webkul\Admin\Http\Controllers\Settings\TypeController; /** @@ -16,8 +17,6 @@ Route::controller(GroupController::class)->prefix('groups')->group(function () { Route::get('', 'index')->name('admin.settings.groups.index'); - Route::get('create', 'create')->name('admin.settings.groups.create'); - Route::post('create', 'store')->name('admin.settings.groups.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.groups.edit'); @@ -58,5 +57,20 @@ Route::delete('{id}', 'destroy')->name('admin.settings.roles.delete'); }); + + /** + * Lead Sources routes. + */ + Route::controller(SourceController::class)->prefix('sources')->group(function () { + Route::get('', 'index')->name('admin.settings.sources.index'); + + Route::post('create', 'store')->name('admin.settings.sources.store'); + + Route::get('edit/{id?}', 'edit')->name('admin.settings.sources.edit'); + + Route::put('edit/{id}', 'update')->name('admin.settings.sources.update'); + + Route::delete('{id}', 'destroy')->name('admin.settings.sources.delete'); + }); }); }); diff --git a/packages/Webkul/Admin/src/Routes/web.php b/packages/Webkul/Admin/src/Routes/web.php index 737eb1a42..1ae9b0d5f 100644 --- a/packages/Webkul/Admin/src/Routes/web.php +++ b/packages/Webkul/Admin/src/Routes/web.php @@ -4,3 +4,13 @@ * Settings routes. */ require 'settings-routes.php'; + +/** + * Products routes. + */ +require 'products-routes.php'; + +/** + * Contacts routes. + */ +require 'contacts-routes.php'; \ No newline at end of file