diff --git a/Modules/Employee/resources/views/create.blade.php b/Modules/Employee/resources/views/create.blade.php index e72d787..3e2bd2e 100644 --- a/Modules/Employee/resources/views/create.blade.php +++ b/Modules/Employee/resources/views/create.blade.php @@ -8,7 +8,9 @@ {{ html()->form('POST')->route('employee.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }} + @include('employee::partials.action') + {{ html()->form()->close() }} diff --git a/Modules/Employee/resources/views/edit.blade.php b/Modules/Employee/resources/views/edit.blade.php index c8e0834..87bd16a 100644 --- a/Modules/Employee/resources/views/edit.blade.php +++ b/Modules/Employee/resources/views/edit.blade.php @@ -7,9 +7,10 @@ @include('layouts.partials.breadcrumb', ['title' => $title]) - {{-- {{ html()->form('POST')->route('employee.store')->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }} --}} {{ html()->modelForm($employee, 'PUT')->route('employee.update', $employee->id)->class(['needs-validation'])->attributes(['novalidate', 'enctype' => 'multipart/form-data'])->open() }} + @include('employee::partials.action') + {{ html()->closeModelForm() }} diff --git a/Modules/Leave/app/Http/Controllers/LeaveController.php b/Modules/Leave/app/Http/Controllers/LeaveController.php index 3ca1131..92e4447 100644 --- a/Modules/Leave/app/Http/Controllers/LeaveController.php +++ b/Modules/Leave/app/Http/Controllers/LeaveController.php @@ -29,6 +29,7 @@ class LeaveController extends Controller public function index() { $data['leaves'] = $this->leaveRepository->findAll(); + return view('leave::index',$data); } @@ -38,6 +39,7 @@ class LeaveController extends Controller public function create() { $data['title'] = 'Create Leave'; + return view('leave::create', $data); } @@ -47,9 +49,13 @@ class LeaveController extends Controller public function store(Request $request): RedirectResponse { $inputData = $request->all(); + try { + $this->leaveRepository->create($inputData); - Toastr()->success('Leave Created Succesfully'); + + toastr()->success('Leave Created Succesfully'); + } catch (\Throwable $th) { toastr()->error($th->getMessage()); } @@ -70,7 +76,9 @@ class LeaveController extends Controller public function edit($id) { $data['title'] = 'Edit Leave'; + $data['leave'] = $this->leaveRepository->getLeaveById($id); + return view('leave::edit',$data); } @@ -81,8 +89,10 @@ class LeaveController extends Controller { $inputData = $request->all(); try { - $this->leaveRepository->update($id,$inputData); + + $this->leaveRepository->update($id, $inputData); toastr()->success('Leave Updated Succesfully'); + } catch (\Throwable $th) { toastr()->error($th->getMessage()); } @@ -95,6 +105,7 @@ class LeaveController extends Controller public function destroy($id) { $this->leaveRepository->delete($id); + toastr()->success('Leave Deleted Succesfully'); } } diff --git a/Modules/Leave/resources/views/edit.blade.php b/Modules/Leave/resources/views/edit.blade.php index 67912e4..37dd0f4 100644 --- a/Modules/Leave/resources/views/edit.blade.php +++ b/Modules/Leave/resources/views/edit.blade.php @@ -24,13 +24,13 @@
-
- @csrf - @method('put') - - @include('leave::partials.action') -
+ + {{ html()->modelForm($leave, 'PUT')->route('leave.update', $leave->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('leave::partials.action') + + {{ html()->closeModelForm() }} +
diff --git a/Modules/Leave/resources/views/index.blade.php b/Modules/Leave/resources/views/index.blade.php index d15471d..01fea4b 100644 --- a/Modules/Leave/resources/views/index.blade.php +++ b/Modules/Leave/resources/views/index.blade.php @@ -49,7 +49,7 @@
Leave Lists
- Add
diff --git a/Modules/Leave/resources/views/partials/action.blade.php b/Modules/Leave/resources/views/partials/action.blade.php index c9219f4..cedca0c 100644 --- a/Modules/Leave/resources/views/partials/action.blade.php +++ b/Modules/Leave/resources/views/partials/action.blade.php @@ -1,15 +1,9 @@
+ -
- Please enter employee name. -
-{{--
- - -
--}}
@@ -23,12 +17,6 @@ value="{{ old('end_date', $leave->end_date ?? '') }}">
-{{-- -
- - -
--}} -
diff --git a/Modules/User/app/Http/Controllers/RoleController.php b/Modules/User/app/Http/Controllers/RoleController.php new file mode 100644 index 0000000..4fbcf40 --- /dev/null +++ b/Modules/User/app/Http/Controllers/RoleController.php @@ -0,0 +1,93 @@ +roleRepository = $roleRepository; + } + /** + * Display a listing of the resource. + */ + public function index() + { + $data['roles'] = $this->roleRepository->findAll(); + $data['editable'] = false; + return view('user::role.index', $data); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $data['permissions'] = Permission::get(); + $data['title'] = "Create Role"; + return view('user::role.create', $data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + $request->validate(['name' => 'required']); + + $role = $this->roleRepository->create($request->all()); + + $role->syncPermissions($request->permissions); + + toastr()->success('New role has been created!'); + + return redirect()->route('role.index'); + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(Role $role) + { + $data['permissions'] = Permission::get(); + $data['role'] = $role; + $data['title'] = "Edit Role"; + return view('user::role.edit', $data); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, Role $role) + { + $role->update(['name' => $request->name]); + $role->syncPermissions($request->permissions); + toastr()->success('Role has been updated!'); + return redirect()->route('role.index'); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Role $role) + { + $role->delete(); + toastr()->success('Role has been deleted!'); + } +} diff --git a/Modules/User/app/Http/Controllers/UserController.php b/Modules/User/app/Http/Controllers/UserController.php index b1a101a..6804efe 100644 --- a/Modules/User/app/Http/Controllers/UserController.php +++ b/Modules/User/app/Http/Controllers/UserController.php @@ -22,9 +22,9 @@ class UserController extends Controller public function index() { - $data = User::latest()->get(); - $editable = false; - return view('user::index', compact('data', 'editable')); + $data['editable'] = false; + $data['users'] = $this->userRepository->findAll(); + return view('user::user.index', $data); } /** @@ -33,8 +33,7 @@ class UserController extends Controller public function create() { $data['title'] = "Create User"; - $data['users'] = User::latest()->get(); - return view('user::create', $data); + return view('user::user.create', $data); } /** @@ -50,7 +49,7 @@ class UserController extends Controller $user = $this->userRepository->create($validatedData, $request->role); toastr()->success('User has been created!'); - return redirect()->route('users.index'); + return redirect()->route('user.index'); } /** @@ -59,7 +58,8 @@ class UserController extends Controller public function show($id) { - return view('user::show'); + $data['user'] = $this->userRepository->getUserById($id); + return view('user::user.show'); } /** @@ -68,8 +68,8 @@ class UserController extends Controller public function edit($id) { $data['title'] = "Edit User"; - $data['user'] = User::findOrFail($id); - return view('user::edit', $data); + $data['user'] = $this->userRepository->getUserById($id); + return view('user::user.edit', $data); } /** diff --git a/Modules/User/app/Providers/UserServiceProvider.php b/Modules/User/app/Providers/UserServiceProvider.php index a694b09..c4be575 100644 --- a/Modules/User/app/Providers/UserServiceProvider.php +++ b/Modules/User/app/Providers/UserServiceProvider.php @@ -4,6 +4,10 @@ namespace Modules\User\Providers; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; +use Modules\User\Repositories\RoleInterface; +use Modules\User\Repositories\RoleRepository; +use Modules\User\Repositories\UserInterface; +use Modules\User\Repositories\UserRepository; class UserServiceProvider extends ServiceProvider { @@ -29,6 +33,8 @@ class UserServiceProvider extends ServiceProvider */ public function register(): void { + $this->app->bind(UserInterface::class, UserRepository::class); + $this->app->bind(RoleInterface::class, RoleRepository::class); $this->app->register(RouteServiceProvider::class); } diff --git a/Modules/User/app/Repositories/RoleInterface.php b/Modules/User/app/Repositories/RoleInterface.php new file mode 100644 index 0000000..90c5af7 --- /dev/null +++ b/Modules/User/app/Repositories/RoleInterface.php @@ -0,0 +1,12 @@ +update($newDetails); + } + +} diff --git a/Modules/User/resources/views/partials/action.blade.php b/Modules/User/resources/views/partials/action.blade.php deleted file mode 100644 index 91c485e..0000000 --- a/Modules/User/resources/views/partials/action.blade.php +++ /dev/null @@ -1,33 +0,0 @@ -
- -
- {{ html()->label('For Employee')->class('form-label') }} - {{ html()->select('employee_id', ['1', '2'])->class('form-select')->placeholder('Select Employee')->required() }} -
- -
- {{ html()->label('Role')->class('form-label') }} - {{ html()->select('role_id', ['1', '2'])->class('form-select')->placeholder('Select Role')->required() }} -
- -
- {{ html()->label('Username')->class('form-label') }} - {{ html()->text('name')->class('form-control')->placeholder('Enter Username')->required() }} -
- -
- {{ html()->label('Email')->class('form-label') }} - {{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }} -
- - -
- {{ html()->label('Password')->class('form-label') }} - {{ html()->password('password')->class('form-control')->placeholder('Enter Password')->required() }} -
- -
- -
- -
diff --git a/Modules/User/resources/views/partials/role/action.blade.php b/Modules/User/resources/views/partials/role/action.blade.php new file mode 100644 index 0000000..2a951df --- /dev/null +++ b/Modules/User/resources/views/partials/role/action.blade.php @@ -0,0 +1,12 @@ +
+ +
+ {{ html()->label('Name')->class('form-label') }} + {{ html()->text('name')->class('form-control')->placeholder('Enter Role Name')->required() }} +
+ +
+ +
+ +
diff --git a/Modules/User/resources/views/partials/view.blade.php b/Modules/User/resources/views/partials/role/view.blade.php similarity index 89% rename from Modules/User/resources/views/partials/view.blade.php rename to Modules/User/resources/views/partials/role/view.blade.php index 00dc733..1d7adec 100644 --- a/Modules/User/resources/views/partials/view.blade.php +++ b/Modules/User/resources/views/partials/role/view.blade.php @@ -8,7 +8,7 @@ diff --git a/Modules/User/resources/views/partials/user/action.blade.php b/Modules/User/resources/views/partials/user/action.blade.php new file mode 100644 index 0000000..cb7618e --- /dev/null +++ b/Modules/User/resources/views/partials/user/action.blade.php @@ -0,0 +1,33 @@ +
+ +
+ {{ html()->label('For Employee')->class('form-label') }} + {{ html()->select('employee_id', ['1', '2'])->class('form-select')->placeholder('Select Employee')->required() }} +
+ +
+ {{ html()->label('Role')->class('form-label') }} + {{ html()->select('role_id', ['1', '2'])->class('form-select')->placeholder('Select Role')->required() }} +
+ +
+ {{ html()->label('Username')->class('form-label') }} + {{ html()->text('name')->class('form-control')->placeholder('Enter Username')->required() }} +
+ +
+ {{ html()->label('Email')->class('form-label') }} + {{ html()->email('email')->class('form-control')->placeholder('Enter Email')->required() }} +
+ + +
+ {{ html()->label('Password')->class('form-label') }} + {{ html()->password('password')->class('form-control')->placeholder('Enter Password')->required() }} +
+ +
+ +
+ +
diff --git a/Modules/User/resources/views/partials/user/view.blade.php b/Modules/User/resources/views/partials/user/view.blade.php new file mode 100644 index 0000000..1d7adec --- /dev/null +++ b/Modules/User/resources/views/partials/user/view.blade.php @@ -0,0 +1,16 @@ + diff --git a/Modules/User/resources/views/edit.blade.php b/Modules/User/resources/views/role/create.blade.php similarity index 86% rename from Modules/User/resources/views/edit.blade.php rename to Modules/User/resources/views/role/create.blade.php index 166da0d..7fa526c 100644 --- a/Modules/User/resources/views/edit.blade.php +++ b/Modules/User/resources/views/role/create.blade.php @@ -15,18 +15,17 @@ -
-
+
-
+ @csrf - @include('user::partials.action', ['btnType' => 'Save']) + @include('user::partials.role.action', ['btnType' => 'Save'])
diff --git a/Modules/User/resources/views/role/edit.blade.php b/Modules/User/resources/views/role/edit.blade.php new file mode 100644 index 0000000..3e64e31 --- /dev/null +++ b/Modules/User/resources/views/role/edit.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') +
+
+ +
+
+
+

{{ $title }}

+ +
+ +
+ +
+
+
+ +
+
+
+
+ {{ html()->modelForm($role, 'PUT')->route('role.update', $role->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('user::partials.role.action', ['btnType' => 'Save']) + + {{ html()->closeModelForm() }} +
+
+
+
+ + +
+ +
+@endsection + +@push('js') + +@endpush diff --git a/Modules/User/resources/views/role/index.blade.php b/Modules/User/resources/views/role/index.blade.php new file mode 100644 index 0000000..898eba1 --- /dev/null +++ b/Modules/User/resources/views/role/index.blade.php @@ -0,0 +1,62 @@ +@extends('layouts.app') +@section('content') +
+
+
+ +
+
+ +
+
Role Lists
+ +
+ +
+
+ + + + + + + + + + + @foreach ($roles as $index => $role) + + + + + + + @endforeach + +
S.NNameGuardAction +
{{ $index + 1 }}{{ $role->name }}{{ $role->guard_name }} +
+ + + + + + +
+
+
+
+
+
+
+
+
+ @include('user::partials.user.view') +@endsection diff --git a/Modules/User/resources/views/create.blade.php b/Modules/User/resources/views/user/create.blade.php similarity index 93% rename from Modules/User/resources/views/create.blade.php rename to Modules/User/resources/views/user/create.blade.php index ca29ca4..cbc1129 100644 --- a/Modules/User/resources/views/create.blade.php +++ b/Modules/User/resources/views/user/create.blade.php @@ -25,7 +25,7 @@
@csrf - @include('user::partials.action', ['btnType' => 'Save']) + @include('user::partials.user.action', ['btnType' => 'Save'])
diff --git a/Modules/User/resources/views/user/edit.blade.php b/Modules/User/resources/views/user/edit.blade.php new file mode 100644 index 0000000..d43dd11 --- /dev/null +++ b/Modules/User/resources/views/user/edit.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') +
+
+ +
+
+
+

{{ $title }}

+ +
+ +
+ +
+
+
+ +
+
+
+
+ {{ html()->modelForm($user, 'PUT')->route('user.update', $user->id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('user::partials.user.action', ['btnType' => 'Save']) + + {{ html()->closeModelForm() }} +
+
+
+
+ + +
+ +
+@endsection + +@push('js') + +@endpush diff --git a/Modules/User/resources/views/index.blade.php b/Modules/User/resources/views/user/index.blade.php similarity index 83% rename from Modules/User/resources/views/index.blade.php rename to Modules/User/resources/views/user/index.blade.php index cff2cde..cd0ae0a 100644 --- a/Modules/User/resources/views/index.blade.php +++ b/Modules/User/resources/views/user/index.blade.php @@ -6,10 +6,15 @@
-
+ +
User Lists
- Add New +
+
@@ -26,7 +31,7 @@ - @foreach ($data as $index => $user) + @foreach ($users as $index => $user) @@ -36,15 +41,15 @@ @@ -59,5 +64,5 @@ - @include('user::partials.view') + @include('user::partials.user.view') @endsection diff --git a/Modules/User/routes/web.php b/Modules/User/routes/web.php index c43ce3b..f857b44 100644 --- a/Modules/User/routes/web.php +++ b/Modules/User/routes/web.php @@ -1,6 +1,7 @@ names('user'); + Route::resource('role', RoleController::class)->names('role'); }); diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php.bak similarity index 100% rename from app/Http/Controllers/RoleController.php rename to app/Http/Controllers/RoleController.php.bak diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 6d721b3..52663e4 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -68,9 +68,10 @@ class="nav-link @if (\Request::is('user/*')) active @endif">Users - {{-- --}} +
{{ $index + 1 }}{{ $user->roles->first()->id }}
- -