From a52221768dac9886e96107409827a07f64a0f38b Mon Sep 17 00:00:00 2001 From: Shivendra Date: Fri, 19 Jul 2024 13:37:18 +0530 Subject: [PATCH 1/4] added roles page translation --- .../Admin/src/Resources/lang/en/app.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index d4dd5297e..326946bca 100644 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -146,9 +146,11 @@ 'id' => 'ID', 'name' => 'Name', ], + 'edit' => [ 'title' => 'Edit Group', ], + 'create' => [ 'name' => 'Name', 'title' => 'Create Group', @@ -157,6 +159,50 @@ ], ], ], + + 'roles' => [ + 'index' => [ + 'create-btn' => 'Create Roles', + 'title' => 'Roles', + 'settings' => 'Settings', + 'datagrid' => [ + 'all' => 'All', + 'custom' => 'Custom', + 'delete' => 'Delete', + 'description' => 'Description', + 'edit' => 'Edit', + 'id' => 'ID', + 'name' => 'Name', + 'permission-type' => 'Permission Type', + ], + ], + + 'create' => [ + 'access-control' => 'Access Control', + 'all' => 'All', + 'back-btn' => 'Back', + 'custom' => 'Custom', + 'description' => 'Description', + 'general' => 'General', + 'name' => 'Name', + 'permissions' => 'Permissions', + 'save-btn' => 'Save Role', + 'title' => 'Create Role', + ], + + 'edit' => [ + 'access-control' => 'Access Control', + 'all' => 'All', + 'back-btn' => 'Back', + 'custom' => 'Custom', + 'description' => 'Description', + 'general' => 'General', + 'name' => 'Name', + 'permissions' => 'Permissions', + 'save-btn' => 'Save Role', + 'title' => 'Edit Role', + ], + ], ], // ----------------------------------------------------------------Old version locale ---------------------------------- From 0242e9add61e87de88cf3cbb037ad8f757132207 Mon Sep 17 00:00:00 2001 From: Shivendra Date: Mon, 22 Jul 2024 10:00:11 +0530 Subject: [PATCH 2/4] Updated Type page --- .../src/DataGrids/Setting/TypeDataGrid.php | 4 +- .../Controllers/Setting/TypeController.php | 62 ++-- .../views/settings/types/index.blade.php | 308 ++++++++++++++---- 3 files changed, 278 insertions(+), 96 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/Setting/TypeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/Setting/TypeDataGrid.php index ea5fedfd5..986abba25 100644 --- a/packages/Webkul/Admin/src/DataGrids/Setting/TypeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/Setting/TypeDataGrid.php @@ -52,15 +52,17 @@ public function prepareColumns(): void public function prepareActions(): void { $this->addAction([ + 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.roles.index.datagrid.edit'), 'method' => 'GET', 'url' => function ($row) { - return route('admin.settings.types.edit', $row->id); + return route('admin.settings.types.update', $row->id); }, ]); $this->addAction([ + 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.roles.index.datagrid.delete'), 'method' => 'DELETE', diff --git a/packages/Webkul/Admin/src/Http/Controllers/Setting/TypeController.php b/packages/Webkul/Admin/src/Http/Controllers/Setting/TypeController.php index 08a7009d4..59c2314c2 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Setting/TypeController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Setting/TypeController.php @@ -4,7 +4,6 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Event; -use Illuminate\Support\Facades\Validator; use Illuminate\View\View; use Webkul\Admin\DataGrids\Setting\TypeDataGrid; use Webkul\Admin\Http\Controllers\Controller; @@ -33,52 +32,41 @@ public function index(): View|JsonResponse /** * Store a newly created type in storage. - * - * @return \Illuminate\Http\Response */ - public function store() + public function store(): JsonResponse { - $validator = Validator::make(request()->all(), [ - 'name' => 'required|unique:lead_types,name', + $this->validate(request(), [ + 'name' => ['required', 'unique:lead_types,name'], ]); - if ($validator->fails()) { - session()->flash('error', trans('admin::app.settings.types.name-exists')); - - return redirect()->back(); - } - Event::dispatch('settings.type.create.before'); - $type = $this->typeRepository->create(request()->all()); + $type = $this->typeRepository->create(request()->only(['name'])); Event::dispatch('settings.type.create.after', $type); - session()->flash('success', trans('admin::app.settings.types.create-success')); - - return redirect()->route('admin.settings.types.index'); + return new JsonResponse([ + 'data' => $type, + 'message' => trans('Lead Type Created successfully'), + ]); } /** * Show the form for editing the specified type. - * - * @param int $id - * @return \Illuminate\View\View */ - public function edit($id) + public function edit(int $id): View|JsonResponse { $type = $this->typeRepository->findOrFail($id); - return view('admin::settings.types.edit', compact('type')); + return new JsonResponse([ + 'data' => $type, + ]); } /** * Update the specified type 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:lead_types,name,'.$id, @@ -86,43 +74,37 @@ public function update($id) Event::dispatch('settings.type.update.before', $id); - $type = $this->typeRepository->update(request()->all(), $id); + $type = $this->typeRepository->update(request()->only(['name'] ), $id); Event::dispatch('settings.type.update.after', $type); - session()->flash('success', trans('admin::app.settings.types.update-success')); - - return redirect()->route('admin.settings.types.index'); + return new JsonResponse([ + 'data' => $type, + 'message' => trans('Lead Type updated successfully'), + ]); } /** * Remove the specified type from storage. - * - * @param int $id - * @return \Illuminate\Http\Response */ - public function destroy($id) + public function destroy(int $id): JsonResponse { $type = $this->typeRepository->findOrFail($id); try { Event::dispatch('settings.type.delete.before', $id); - $this->typeRepository->delete($id); + $type->delete($id); Event::dispatch('settings.type.delete.after', $id); - return response()->json([ + return new JsonResponse([ 'message' => trans('admin::app.settings.types.delete-success'), ], 200); } catch (\Exception $exception) { - return response()->json([ + return new JsonResponse([ 'message' => trans('admin::app.settings.types.delete-failed'), ], 400); } - - return response()->json([ - 'message' => trans('admin::app.settings.types.delete-failed'), - ], 400); } } 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 e5e773370..a1ff54a12 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 @@ -1,72 +1,270 @@ -@extends('admin::layouts.master') + + + @lang('Types') + -@section('page_title') - {{ __('admin::app.settings.types.title') }} -@stop + + + + + + -@section('content-wrapper') -
- -