first commit
This commit is contained in:
95
Modules/Payroll/app/Http/Controllers/PaymentController.php
Normal file
95
Modules/Payroll/app/Http/Controllers/PaymentController.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Payroll\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Employee\Repositories\EmployeeInterface;
|
||||
use Modules\Employee\Repositories\EmployeeRepository;
|
||||
use Modules\Payroll\Repositories\PaymentInterface;
|
||||
use Modules\Payroll\Repositories\PaymentRepository;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
private $paymentRepository;
|
||||
private $employeeRepository;
|
||||
|
||||
public function __construct(PaymentInterface $paymentRepository, EmployeeInterface $employeeRepository)
|
||||
{
|
||||
$this->paymentRepository = $paymentRepository;
|
||||
$this->employeeRepository = $employeeRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['title'] = "Payment Lists";
|
||||
$data['paymentLists'] = $this->paymentRepository->findAll();
|
||||
return view('payroll::payments.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data['title'] = "Create Payment";
|
||||
$data['editable'] = false;
|
||||
$data['employeeLists'] = $this->employeeRepository->pluck();
|
||||
return view('payroll::payments.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->paymentRepository->create($request->all());
|
||||
toastr()->success('Payment Created Successfully.');
|
||||
return redirect()->route('payment.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('payroll::payments.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$data['title'] = "Edit Payment";
|
||||
$data['editable'] = true;
|
||||
$data['payment'] = $this->paymentRepository->getPaymentById($id);
|
||||
return view('payroll::payments.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->paymentRepository->update($id, $request->all());
|
||||
toastr()->success('Payment Updated Successfully.');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
}
|
||||
return redirect()->route('payment.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user