diff --git a/Modules/Employee/app/Http/Controllers/EmployeeController.php b/Modules/Employee/app/Http/Controllers/EmployeeController.php index 8d9da57..3fdb764 100644 --- a/Modules/Employee/app/Http/Controllers/EmployeeController.php +++ b/Modules/Employee/app/Http/Controllers/EmployeeController.php @@ -3,13 +3,13 @@ namespace Modules\Employee\Http\Controllers; use App\Http\Controllers\Controller; -use App\Models\Role; use Carbon\Carbon; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; use Modules\Employee\Repositories\EmployeeInterface; use Modules\User\Repositories\UserInterface; +use Spatie\Permission\Models\Role; class EmployeeController extends Controller { @@ -53,6 +53,7 @@ class EmployeeController extends Controller */ public function store(Request $request) { + dd($request->all()); $inputData = $request->all(); try { @@ -63,8 +64,11 @@ class EmployeeController extends Controller } $this->employeeRepository->create($inputData); + toastr()->success('Employee Created Succesfully'); + } catch (\Throwable $th) { + echo $th->getMessage(); toastr()->error($th->getMessage()); } return redirect()->route('employee.index'); @@ -114,19 +118,25 @@ class EmployeeController extends Controller /** * Remove the specified resource from storage. */ - public function destroy($id) + public function destroy(Request $request) { try { - $employeeModel = $this->employeeRepository->getEmployeeById($id); - $employeeModel->user->roles()->detach(); - $employeeModel->user->delete(); - $employeeModel->delete(); + + $employeeModel = $this->employeeRepository->getEmployeeById($request->id); + + optional($employeeModel)->user?->roles()?->detach(); + + optional($employeeModel)->user?->delete(); + + optional($employeeModel)->delete(); + toastr()->success('Employee Delete Succesfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } - return redirect()->route('employee.index'); + + return response()->json(['status' => true, 'message' => 'Employee Delete Succesfully']); } @@ -153,4 +163,14 @@ class EmployeeController extends Controller return redirect()->route('employee.index'); } + public function changePassword(Request $request) + { + dd($request->all()); + try { + + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + } + } diff --git a/Modules/Employee/resources/views/index.blade.php b/Modules/Employee/resources/views/index.blade.php index adb94d1..bd7d1a0 100644 --- a/Modules/Employee/resources/views/index.blade.php +++ b/Modules/Employee/resources/views/index.blade.php @@ -42,7 +42,8 @@ @forelse ($employees as $employee)
-
+
+
@if ($employee->user) @@ -69,9 +70,11 @@
-
+
+ +
{{ $employee->first_name }}
diff --git a/Modules/Employee/routes/web.php b/Modules/Employee/routes/web.php index 45acc1c..c24c682 100644 --- a/Modules/Employee/routes/web.php +++ b/Modules/Employee/routes/web.php @@ -14,10 +14,16 @@ use Modules\Employee\Http\Controllers\EmployeeController; | */ -Route::group(['middleware' => 'auth'], function () { - Route::post('assignRole', [EmployeeController::class, 'assignRole'])->name('employee.assignRole'); - Route::resource('employee', EmployeeController::class)->names('employee'); - Route::group(['prefix' => 'employee'], function () { - }); +Route::middleware('auth')->group( + function () { -}); + Route::prefix('employee')->as('employee.')->group(function () { + + Route::post('assignRole', [EmployeeController::class, 'assignRole'])->name('assignRole'); + Route::post('changePassword', [EmployeeController::class, 'changePassword'])->name('assignRole'); + }); + + Route::resource('employee', EmployeeController::class)->names('employee'); + + } +); diff --git a/app/Models/Branches.php b/app/Models/Branches.php new file mode 100644 index 0000000..88382ec --- /dev/null +++ b/app/Models/Branches.php @@ -0,0 +1,16 @@ +create(); + // \App\Models\User::factory(10)->create(); $admin = \App\Models\User::factory()->create([ 'name' => 'Admin User', 'email' => 'admin@gmail.com', - 'password' => Hash::make('password'), + 'employee_id' => 1, + 'password' => bcrypt('password'), ]); $member = \App\Models\User::factory()->create([ 'name' => 'Member User', 'email' => 'member@gmail.com', - 'password' => Hash::make('password'), + 'employee_id' => 2, + 'password' => bcrypt('password'), ]); diff --git a/public/assets/js/custom.js b/public/assets/js/custom.js index 78053bb..4410e7f 100644 --- a/public/assets/js/custom.js +++ b/public/assets/js/custom.js @@ -24,7 +24,9 @@ $('body').on('click', '.remove-item-btn', function (e) { id: id }, success: function (response) { - location.reload(); + if(response.status == true){ + location.reload(); + } }, error: function (xhr, status, error) { console.error(xhr.responseText); diff --git a/resources/views/crud/generated/cities/edit.blade.php b/resources/views/crud/generated/cities/edit.blade.php index 9a1f150..a43f4a7 100644 --- a/resources/views/crud/generated/cities/edit.blade.php +++ b/resources/views/crud/generated/cities/edit.blade.php @@ -1,30 +1,47 @@ @extends('layouts.app') @section('content') -
-
-

{{ label('Add Cities') }}

- +
+
-
-
-
- @csrf -
-
- {{ createCustomSelect('tbl_districts', 'title', 'district_id', $editable ? $data->districts_id : '', 'Districts Id', 'districts_id', 'form-control select2', 'status<>-1') }} -
-
{{ createText('title', 'title', 'Title', '', $editable ? $data->title : '') }} -
-
- {{ createTextarea('description', 'description ckeditor-classic', 'Description', $editable ? $data->description : '') }} -
-
{{ createPlainTextArea('remarks', '', 'Remarks', $editable ? $data->remarks : '') }} -
-
- -
- + + @include('layouts.partials.breadcrumb', ['title' => 'City']) + + +
+
+
+ + @csrf + + +
+ +
+ {{ createText('title', 'title', 'Title', '', $editable ? $data->title : '') }} +
+ +
+ {{ createCustomSelect('tbl_districts', 'title', 'district_id', $editable ? $data->districts_id : '', 'District', 'districts_id', 'form-control select2', 'status<>-1') }} +
+ + + {{--
+ {{ createTextarea('description', 'description ckeditor-classic', 'Description', $editable ? $data->description : '') }} +
--}} + +
+ {{ createPlainTextArea('remarks', '', 'Remarks', $editable ? $data->remarks : '') }} +
+ +
+ + +
+ + +
+
@endsection diff --git a/resources/views/crud/generated/cities/index.blade.php b/resources/views/crud/generated/cities/index.blade.php index 48f5e54..623a3d4 100644 --- a/resources/views/crud/generated/cities/index.blade.php +++ b/resources/views/crud/generated/cities/index.blade.php @@ -1,105 +1,97 @@ @extends('layouts.app') @section('content') -
- -
- - - - - - - - - - - - @php - $i = 1; - @endphp - @foreach ($data as $item) - - - - - - - - @endforeach - - -
{{ label('Sn.') }}{{ label('districts') }}{{ label('title') }}{{ label('alias') }}{{ label('Action') }} -
{{ $i++ }} - {!! getFieldData('tbl_districts', 'title', 'district_id', $item->districts_id) !!} - {{ $item->title }} -
- {{ $item->alias }} - -
- change alias -
- - - -
+
+ + + + + + + + + + + + @foreach ($data as $item) + + + + + + + + @endforeach + +
{{ label('Sn.') }}{{ label('District') }}{{ label('title') }}{{ label('alias') }}{{ label('Action') }} +
{{ $index + 1 }} + {!! getFieldData('tbl_districts', 'title', 'district_id', $item->districts_id) !!} + {{ $item->title }} +
+ {{ $item->alias }} + +
+ change alias +
+ +
+
+
@endsection -@push('css') - - -@endpush + @push('js') - - - - - - - - -