-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1230d7
commit 5ac69d8
Showing
8 changed files
with
275 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/Http/Composer/Dashboard/Tenancies/RentBook/DashboardTenanciesRentBookAddComposer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
namespace FullRent\Core\Application\Http\Composer\Dashboard\Tenancies\RentBook; | ||
|
||
use FullRent\Core\Application\Http\Composer\Composer; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Routing\Router; | ||
|
||
/** | ||
* Class DashboardTenanciesRentBookAddComposer | ||
* @package FullRent\Core\Application\Http\Composer\Dashboard\Tenancies\RentBook | ||
* @author Simon Bennett <simon@bennett.im> | ||
*/ | ||
final class DashboardTenanciesRentBookAddComposer implements Composer | ||
{ | ||
|
||
/** @var Router */ | ||
private $router; | ||
|
||
/** | ||
* DashboardTenanciesRentBookChangeComposer constructor. | ||
* @param Router $router | ||
*/ | ||
public function __construct(Router $router) | ||
{ | ||
$this->router = $router; | ||
} | ||
|
||
/** | ||
* @param View $view | ||
*/ | ||
public function compose(View $view) | ||
{ | ||
$view->with('tenancyId', $this->router->current()->parameter('tenancyId')); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
app/Http/Composer/Dashboard/Tenancies/RentBook/DashboardTenanciesRentBookChangeComposer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
namespace FullRent\Core\Application\Http\Composer\Dashboard\Tenancies\RentBook; | ||
|
||
use FullRent\Core\Application\Http\Composer\Composer; | ||
use FullRent\Core\QueryBus\QueryBus; | ||
use FullRent\Core\Tenancy\Queries\FindTenancyRentBookPayment; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Routing\Router; | ||
|
||
/** | ||
* Class DashboardTenanciesRentBookChangeComposer | ||
* @package FullRent\Core\Application\Http\Composer\Dashboard\Tenancies\RentBook | ||
* @author Simon Bennett <simon@bennett.im> | ||
*/ | ||
final class DashboardTenanciesRentBookChangeComposer implements Composer | ||
{ | ||
/** @var QueryBus */ | ||
private $queryBus; | ||
|
||
/** @var Router */ | ||
private $router; | ||
|
||
/** | ||
* DashboardTenanciesRentBookChangeComposer constructor. | ||
* @param QueryBus $queryBus | ||
* @param Router $router | ||
*/ | ||
public function __construct(QueryBus $queryBus, Router $router) | ||
{ | ||
$this->queryBus = $queryBus; | ||
$this->router = $router; | ||
} | ||
|
||
/** | ||
* @param View $view | ||
*/ | ||
public function compose(View $view) | ||
{ | ||
$tenancyId = $this->router->current()->parameter('tenancyId'); | ||
$rentPaymentId = $this->router->current()->parameter('rentPaymentId'); | ||
|
||
$rentPayment = $this->queryBus->query(new FindTenancyRentBookPayment($rentPaymentId)); | ||
|
||
$view->with( | ||
[ | ||
'tenancyId' => $tenancyId, | ||
'rentPaymentId' => $rentPaymentId, | ||
'rentPayment' => $rentPayment | ||
]); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
app/Http/Controllers/Tenancies/RentBook/TenanciesRentBookController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
namespace FullRent\Core\Application\Http\Controllers\Tenancies\RentBook; | ||
|
||
use FullRent\Core\Application\Http\Controllers\Controller; | ||
use FullRent\Core\Application\Http\Requests\Tenancies\RentBook\ChangeRentBookPaymentInfoRequest; | ||
use FullRent\Core\Tenancy\Commands\AmendScheduledTenancyRentPayment; | ||
use FullRent\Core\Tenancy\Commands\RemoveScheduledRentPayment; | ||
use FullRent\Core\Tenancy\Commands\ScheduleTenancyRentPayment; | ||
use Illuminate\Http\Request; | ||
use SmoothPhp\Contracts\CommandBus\CommandBus; | ||
|
||
/** | ||
* Class TenanciesRentBookController | ||
* @package FullRent\Core\Application\Http\Controllers\Tenancies\RentBook | ||
* @author Simon Bennett <simon@bennett.im> | ||
*/ | ||
final class TenanciesRentBookController extends Controller | ||
{ | ||
/** @var CommandBus */ | ||
private $commandBus; | ||
|
||
/** | ||
* TenanciesRentBookController constructor. | ||
* @param CommandBus $commandBus | ||
*/ | ||
public function __construct(CommandBus $commandBus) | ||
{ | ||
$this->commandBus = $commandBus; | ||
} | ||
|
||
/** | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function change() | ||
{ | ||
return view('dashboard.tenancies.rentbook.change'); | ||
} | ||
|
||
public function add() | ||
{ | ||
return view('dashboard.tenancies.rentbook.add'); | ||
} | ||
|
||
|
||
/** | ||
* @param Request $request | ||
* @param $tenancyId | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function addPayment(Request $request, $tenancyId) | ||
{ | ||
$this->commandBus->execute(new ScheduleTenancyRentPayment(uuid(), | ||
$tenancyId, | ||
$request->get('rent_amount'), | ||
$request->get('rent_due'))); | ||
sleep(2); | ||
|
||
return redirect("tenancies/{$tenancyId}#rentbook") | ||
->with($this->notification('Rent Scheduled', 'Your rent payment has been scheduled.')); | ||
} | ||
|
||
/** | ||
* @param ChangeRentBookPaymentInfoRequest $request | ||
* @param $tenancyId | ||
* @param $rentPaymentId | ||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector | ||
*/ | ||
public function updateRentPayment(ChangeRentBookPaymentInfoRequest $request, $tenancyId, $rentPaymentId) | ||
{ | ||
$this->commandBus->execute(new AmendScheduledTenancyRentPayment($tenancyId, | ||
$rentPaymentId, | ||
$request->get('rent_amount'), | ||
$request->get('rent_due'))); | ||
|
||
sleep(2); | ||
|
||
return redirect("tenancies/{$tenancyId}#rentbook") | ||
->with($this->notification('Rent Updated', 'Your rent payment has been updated')); | ||
} | ||
|
||
/** | ||
* @param $tenancyId | ||
* @param $rentPaymentId | ||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector | ||
*/ | ||
public function deleteRentPayment($tenancyId, $rentPaymentId) | ||
{ | ||
|
||
$this->commandBus->execute(new RemoveScheduledRentPayment($tenancyId, $rentPaymentId)); | ||
|
||
sleep(2); | ||
|
||
return redirect("tenancies/{$tenancyId}#rentbook") | ||
->with($this->notification('Rent Payment Deleted', 'Success the rent payment has been deleted')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/Http/Requests/Tenancies/RentBook/ChangeRentBookPaymentInfoRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
namespace FullRent\Core\Application\Http\Requests\Tenancies\RentBook; | ||
|
||
use FullRent\Core\Application\Http\Requests\Request; | ||
|
||
/** | ||
* Class ChangeRentBookPaymentInfoRequest | ||
* @package FullRent\Core\Application\Http\Requests\Tenancies\RentBook | ||
* @author Simon Bennett <simon@bennett.im> | ||
*/ | ||
final class ChangeRentBookPaymentInfoRequest extends Request | ||
{ | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'rent_amount' => 'required', | ||
'rent_due' => 'required|date_format:d/m/Y' | ||
]; | ||
} | ||
|
||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters