|
|
|
@ -17,13 +17,27 @@ use App\Http\Requests\Payments\UpdateRequest; |
|
|
|
*/ |
|
|
|
class PaymentsController extends Controller |
|
|
|
{ |
|
|
|
/** |
|
|
|
* @var \App\Entities\Payments\PaymentsRepository |
|
|
|
*/ |
|
|
|
private $repo; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create new Payments Controller. |
|
|
|
* |
|
|
|
* @param \App\Entities\Payments\PaymentsRepository $repo |
|
|
|
*/ |
|
|
|
public function __construct(PaymentsRepository $repo) |
|
|
|
{ |
|
|
|
$this->repo = $repo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show payment list. |
|
|
|
* |
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function index(Request $request) |
|
|
|
{ |
|
|
|
$payments = $this->repo->getPayments($request->only('q', 'partner_id')); |
|
|
|
@ -32,6 +46,11 @@ class PaymentsController extends Controller |
|
|
|
return view('payments.index', compact('payments', 'partnersList')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show create payment form. |
|
|
|
* |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function create() |
|
|
|
{ |
|
|
|
$projects = $this->repo->getProjectsList(); |
|
|
|
@ -40,6 +59,12 @@ class PaymentsController extends Controller |
|
|
|
return view('payments.create', compact('projects', 'partners')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Store new payment to database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\Payments\CreateRequest $request |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function store(CreateRequest $request) |
|
|
|
{ |
|
|
|
$payment = $this->repo->create($request->except('_token')); |
|
|
|
@ -48,11 +73,23 @@ class PaymentsController extends Controller |
|
|
|
return redirect()->route('projects.payments', $payment->project_id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show a payment detail. |
|
|
|
* |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function show(Payment $payment) |
|
|
|
{ |
|
|
|
return view('payments.show', compact('payment')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show a payment edit form. |
|
|
|
* |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function edit(Payment $payment) |
|
|
|
{ |
|
|
|
$projects = $this->repo->getProjectsList(); |
|
|
|
@ -61,6 +98,13 @@ class PaymentsController extends Controller |
|
|
|
return view('payments.edit', compact('payment', 'projects', 'partners')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Update a payment on database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\Payments\UpdateRequest $request |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function update(UpdateRequest $request, Payment $payment) |
|
|
|
{ |
|
|
|
$paymentData = $request->validated(); |
|
|
|
@ -78,11 +122,24 @@ class PaymentsController extends Controller |
|
|
|
return redirect()->route('payments.show', $payment->id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show payment delete confirmation page. |
|
|
|
* |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function delete(Payment $payment) |
|
|
|
{ |
|
|
|
return view('payments.delete', compact('payment')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Delete a payment from database. |
|
|
|
* |
|
|
|
* @param \App\Http\Requests\Payments\DeleteRequest $paymentDeleteRequest |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\Routing\Redirector |
|
|
|
*/ |
|
|
|
public function destroy(DeleteRequest $request, Payment $payment) |
|
|
|
{ |
|
|
|
$projectId = $payment->project_id; |
|
|
|
@ -96,6 +153,12 @@ class PaymentsController extends Controller |
|
|
|
return redirect()->route('projects.payments', $projectId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Print payment receipt. |
|
|
|
* |
|
|
|
* @param \App\Entities\Payments\Payment $payment |
|
|
|
* @return \Illuminate\View\View |
|
|
|
*/ |
|
|
|
public function pdf(Payment $payment) |
|
|
|
{ |
|
|
|
return view('payments.pdf', compact('payment')); |
|
|
|
|