first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
<?php
namespace Modules\Admin\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Admin\Models\Department;
use Modules\Admin\Repositories\DepartmentRepository;
use Modules\Employee\Repositories\EmployeeRepository;
class DepartmentController extends Controller
{
private $departmentRepository;
private $employeeRepository;
public function __construct(DepartmentRepository $departmentRepository,
EmployeeRepository $employeeRepository) {
$this->departmentRepository = $departmentRepository;
$this->employeeRepository = $employeeRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
// toastr()
// ->info('Welcome back')
// ->success('Data has been saved successfully!')
// ->warning('Are you sure you want to proceed ?');
$data['title'] = 'Department List';
$data['departmentLists'] = $this->departmentRepository->findAll();
return view('admin::departments.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
// toastr('Department has been created!', 'success');
$data['title'] = 'Create Department';
$data['editable'] = false;
$data['employeeLists'] = $this->employeeRepository->pluck();
return view('admin::departments.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
// try {
$this->departmentRepository->create($request->all());
// toastr()->success('Department has been created!');
// } catch (\Throwable $th) {
// toastr()->error($th->getMessage());
// }
// toastr('Department has been created!', 'success');
// return back();
return redirect()->route('department.index')->with('sucess', 'adw');
}
/**
* Show the specified resource.
*/
public function show(Department $department)
{
$data['department'] = $department;
return view('admin::departments.show', $data);
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$data['title'] = 'Edit Department';
$data['editable'] = true;
$data['employeeLists'] = $this->employeeRepository->pluck();
$data['department'] = $this->departmentRepository->getDepartmentById($id);
return view('admin::departments.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request,Department $department): RedirectResponse
{
// dd($request->all())
try {
$department->update($request->except(['_token', '_method']));
// $this->departmentRepository->update($id, $request->except(['_token', '_method']));
toastr()->success('Department has been updated!');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('department.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$this->departmentRepository->delete($id);
toastr()->success('Department Deleted Succesfully');
return response()->json(['status' => true, 'message' => 'Department Delete Succesfully']);
}
}