pms module status dynamic
This commit is contained in:
123
Modules/PMS/app/Http/Controllers/ProjectController.php
Normal file
123
Modules/PMS/app/Http/Controllers/ProjectController.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\PMS\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Employee\Repositories\EmployeeInterface;
|
||||
use Modules\PMS\Models\Project;
|
||||
use Modules\PMS\Repositories\ClientInterface;
|
||||
use Modules\PMS\Repositories\ProjectInterface;
|
||||
|
||||
class ProjectController extends Controller
|
||||
{
|
||||
private $projectRepository;
|
||||
private $clientRepository;
|
||||
private $employeeRepository;
|
||||
|
||||
public function __construct(
|
||||
ProjectInterface $projectRepository,
|
||||
ClientInterface $clientRepository,
|
||||
EmployeeInterface $employeeRepository) {
|
||||
$this->projectRepository = $projectRepository;
|
||||
$this->clientRepository = $clientRepository;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = 'Project List';
|
||||
$data['projects'] = $this->projectRepository->findAll();
|
||||
return view('pms::project.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = 'Create Project';
|
||||
$data['status'] = Project::STATUS;
|
||||
$data['categoryList'] = Project::CATEGORY;
|
||||
$data['clientList'] = $this->clientRepository->pluck();
|
||||
$data['memberList'] = $this->employeeRepository->pluck();
|
||||
|
||||
return view('pms::project.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$inputData = $request->all();
|
||||
try {
|
||||
$this->projectRepository->create($inputData);
|
||||
toastr()->success('Project Created Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('project.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$data['title'] = 'View Project';
|
||||
$data['project'] = $this->projectRepository->getProjectById($id);
|
||||
$data['status'] = Project::STATUS;
|
||||
$data['countryList'] = [1 => 'Nepal'];
|
||||
return view('pms::project.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = 'Edit Project';
|
||||
$data['project'] = $this->projectRepository->getProjectById($id);
|
||||
$data['status'] = Project::STATUS;
|
||||
$data['categoryList'] = Project::CATEGORY;
|
||||
$data['clientList'] = $this->clientRepository->pluck();
|
||||
$data['memberList'] = $this->employeeRepository->pluck();
|
||||
return view('pms::project.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$inputData = $request->except(['_method', '_token']);
|
||||
try {
|
||||
$this->projectRepository->update($id, $inputData);
|
||||
toastr()->success('Project Update Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('project.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->projectRepository->delete($id);
|
||||
|
||||
toastr()->success('Project Deleted Succesfully');
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user