Merge remote-tracking branch 'origin/master'

This commit is contained in:
omair saleh
2020-11-25 20:17:32 +08:00
23 changed files with 168 additions and 1042 deletions
@@ -9,20 +9,8 @@ use App\Classes\Modules\Segments\Services\FetchesSegment;
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanCreateSegmentConstant;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantTax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantBillingFee;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantServiceCharge;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantBookingAmountMax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantPaymentAttemptExpiryTime;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstant;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
use App\Http\Resources\SegmentConstantResource;
@@ -46,20 +34,8 @@ class CreateSegmentConstantLogic extends AbstractControllerLogic
/** @var CanCreateSegmentConstant */
private $canCreateSegmentConstant;
/** @var CreatesSegmentConstantTax */
private $createsSegmentConstantTax;
/** @var CreatesSegmentConstantBillingFee */
private $createsSegmentConstantBillingFee;
/** @var CreatesSegmentConstantServiceCharge */
private $createsSegmentConstantServiceCharge;
/** @var CreatesSegmentConstantBookingAmountMax */
private $createsSegmentConstantBookingAmountMax;
/** @var CreatesSegmentConstantPaymentAttemptExpiryTime */
private $createsSegmentConstantPaymentAttemptExpiryTime;
/** @var CreatesSegmentConstant */
private $createsSegmentConstant;
/** @var FetchesSegmentConstant */
private $fetchesSegmentConstant;
@@ -70,31 +46,19 @@ class CreateSegmentConstantLogic extends AbstractControllerLogic
/**
* CreateSegmentConstantLogic constructor.
* @param CanCreateSegmentConstant $canCreateSegmentConstant
* @param CreatesSegmentConstantTax $createsSegmentConstantTax
* @param CreatesSegmentConstantBillingFee $createsSegmentConstantBillingFee
* @param CreatesSegmentConstantServiceCharge $createsSegmentConstantServiceCharge
* @param CreatesSegmentConstantBookingAmountMax $createsSegmentConstantBookingAmountMax
* @param CreatesSegmentConstantPaymentAttemptExpiryTime $createsSegmentConstantPaymentAttemptExpiryTime
* @param createsSegmentConstant $createsSegmentConstantTax
* @param FetchesSegmentConstant $fetchesSegmentConstant
* @param FetchesSegment $fetchesSegment
*/
public function __construct(
CanCreateSegmentConstant $canCreateSegmentConstant,
CreatesSegmentConstantTax $createsSegmentConstantTax,
CreatesSegmentConstantBillingFee $createsSegmentConstantBillingFee,
CreatesSegmentConstantServiceCharge $createsSegmentConstantServiceCharge,
CreatesSegmentConstantBookingAmountMax $createsSegmentConstantBookingAmountMax,
CreatesSegmentConstantPaymentAttemptExpiryTime $createsSegmentConstantPaymentAttemptExpiryTime,
CreatesSegmentConstant $createsSegmentConstant,
FetchesSegmentConstant $fetchesSegmentConstant,
FetchesSegment $fetchesSegment
)
{
$this->canCreateSegmentConstant = $canCreateSegmentConstant;
$this->createsSegmentConstantTax = $createsSegmentConstantTax;
$this->createsSegmentConstantBillingFee = $createsSegmentConstantBillingFee;
$this->createsSegmentConstantServiceCharge = $createsSegmentConstantServiceCharge;
$this->createsSegmentConstantBookingAmountMax = $createsSegmentConstantBookingAmountMax;
$this->createsSegmentConstantPaymentAttemptExpiryTime = $createsSegmentConstantPaymentAttemptExpiryTime;
$this->createsSegmentConstant = $createsSegmentConstant;
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
$this->fetchesSegment = $fetchesSegment;
}
@@ -113,71 +77,24 @@ class CreateSegmentConstantLogic extends AbstractControllerLogic
'id' => $request->input('segment_id'),
]);
$segment_constant_query = $this->fetchesSegmentConstant->execute([
$standard_segment_constant_query = $this->fetchesSegmentConstant->execute([
'id' => $request->input('standard_segment_constant_id'),
]);
]);
if ($segment_constant_query->reference == 'TAX') {
$segment_constant_object = new SegmentConstantTaxObject(
$request->input('segment_id'),
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$segment_constant_object = new SegmentConstantObject(
$request->input('segment_id'),
$standard_segment_constant_query->name,
$standard_segment_constant_query->reference,
$standard_segment_constant_query->detail->type,
$request->input('detail')
);
$this->canCreateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->createsSegmentConstantTax->execute($segment_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
$segment_constant_object = new SegmentConstantBillingFeeObject(
$request->input('segment_id'),
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canCreateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->createsSegmentConstantBillingFee->execute($segment_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
$segment_constant_object = new SegmentConstantServiceChargeObject(
$request->input('segment_id'),
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canCreateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->createsSegmentConstantServiceCharge->execute($segment_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
$request->input('segment_id'),
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value'),
$segment_constant_query->detail->currency_id
);
$this->canCreateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->createsSegmentConstantBookingAmountMax->execute($segment_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
$request->input('segment_id'),
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canCreateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->createsSegmentConstantPaymentAttemptExpiryTime->execute($segment_query, $segment_constant_object);
}
$this->canCreateSegmentConstant->passes($segment_constant_object);
$standard_segment_constant_query = $this->createsSegmentConstant->execute($segment_query, $segment_constant_object);
DB::commit();
return $this->resourceResponse(new SegmentConstantResource($segment_constant_query));
return $this->resourceResponse(new SegmentConstantResource($standard_segment_constant_query));
} catch (\Exception $exception) {
throw new ErrorException($exception->getMessage(), $exception->getCode());
@@ -6,22 +6,10 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateStandardSegmentConstant;
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateSegmentConstant;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantTax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBillingFee;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantServiceCharge;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBookingAmountMax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantPaymentAttemptExpiryTime;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstant;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
use App\Http\Resources\SegmentConstantResource;
@@ -43,53 +31,29 @@ class UpdateSegmentConstantLogic extends AbstractControllerLogic
];
}
/** @var CanUpdateStandardSegmentConstant */
private $canUpdateStandardSegmentConstant;
/** @var CanUpdateSegmentConstant */
private $canUpdateSegmentConstant;
/** @var UpdatesSegmentConstantTax */
private $updatesSegmentConstantTax;
/** @var UpdatesSegmentConstantBillingFee */
private $updatesSegmentConstantBillingFee;
/** @var UpdatesSegmentConstantServiceCharge */
private $updatesSegmentConstantServiceCharge;
/** @var UpdatesSegmentConstantBookingAmountMax */
private $updatesSegmentConstantBookingAmountMax;
/** @var UpdatesSegmentConstantPaymentAttemptExpiryTime */
private $updatesSegmentConstantPaymentAttemptExpiryTime;
/** @var UpdatesSegmentConstant */
private $updatesSegmentConstant;
/** @var FetchesSegmentConstant */
private $fetchesSegmentConstant;
/**
* UpdateStandardSegmentConstantLogic constructor.
* @param CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant
* @param UpdatesSegmentConstantTax $updatesSegmentConstantTax
* @param UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee
* @param UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge
* @param UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax
* @param UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime
* @param CanUpdateSegmentConstant $canUpdateSegmentConstant
* @param UpdatesSegmentConstant $updatesSegmentConstant
* @param FetchesSegmentConstant $fetchesSegmentConstant
*/
public function __construct(
CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant,
UpdatesSegmentConstantTax $updatesSegmentConstantTax,
UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee,
UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge,
UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax,
UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime,
CanUpdateSegmentConstant $canUpdateSegmentConstant,
UpdatesSegmentConstant $updatesSegmentConstant,
FetchesSegmentConstant $fetchesSegmentConstant
)
{
$this->canUpdateStandardSegmentConstant = $canUpdateStandardSegmentConstant;
$this->updatesSegmentConstantTax = $updatesSegmentConstantTax;
$this->updatesSegmentConstantBillingFee = $updatesSegmentConstantBillingFee;
$this->updatesSegmentConstantServiceCharge = $updatesSegmentConstantServiceCharge;
$this->updatesSegmentConstantBookingAmountMax = $updatesSegmentConstantBookingAmountMax;
$this->updatesSegmentConstantPaymentAttemptExpiryTime = $updatesSegmentConstantPaymentAttemptExpiryTime;
$this->canUpdateSegmentConstant = $canUpdateSegmentConstant;
$this->updatesSegmentConstant = $updatesSegmentConstant;
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
}
@@ -105,63 +69,16 @@ class UpdateSegmentConstantLogic extends AbstractControllerLogic
$segment_constant_query = $this->fetchesSegmentConstant->execute(['id' => $request->route('id')]);
if ($segment_constant_query->reference == 'TAX') {
$segment_constant_object = new SegmentConstantTaxObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$segment_constant_object = new SegmentConstantObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('detail')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantTax->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
$segment_constant_object = new SegmentConstantBillingFeeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantBillingFee->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
$segment_constant_object = new SegmentConstantServiceChargeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantServiceCharge->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value'),
$segment_constant_query->detail->currency_id
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantBookingAmountMax->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantPaymentAttemptExpiryTime->execute($segment_constant_query, $segment_constant_object);
}
$this->canUpdateSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstant->execute($segment_constant_query, $segment_constant_object);
DB::commit();
@@ -8,20 +8,8 @@ use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateStandardSegmentConstant;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantTax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBillingFee;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantServiceCharge;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBookingAmountMax;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantPaymentAttemptExpiryTime;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstant;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
use App\Http\Resources\SegmentConstantResource;
@@ -32,7 +20,6 @@ use Illuminate\Support\Facades\DB;
class UpdateStandardSegmentConstantLogic extends AbstractControllerLogic
{
/**
* @return array
*/
@@ -47,19 +34,7 @@ class UpdateStandardSegmentConstantLogic extends AbstractControllerLogic
private $canUpdateStandardSegmentConstant;
/** @var UpdatesSegmentConstantTax */
private $updatesSegmentConstantTax;
/** @var UpdatesSegmentConstantBillingFee */
private $updatesSegmentConstantBillingFee;
/** @var UpdatesSegmentConstantServiceCharge */
private $updatesSegmentConstantServiceCharge;
/** @var UpdatesSegmentConstantBookingAmountMax */
private $updatesSegmentConstantBookingAmountMax;
/** @var UpdatesSegmentConstantPaymentAttemptExpiryTime */
private $updatesSegmentConstantPaymentAttemptExpiryTime;
private $updatesSegmentConstant;
/** @var FetchesSegmentConstant */
private $fetchesSegmentConstant;
@@ -67,29 +42,17 @@ class UpdateStandardSegmentConstantLogic extends AbstractControllerLogic
/**
* UpdateStandardSegmentConstantLogic constructor.
* @param CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant
* @param UpdatesSegmentConstantTax $updatesSegmentConstantTax
* @param UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee
* @param UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge
* @param UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax
* @param UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime
* @param UpdatesSegmentConstant $updatesSegmentConstant
* @param FetchesSegmentConstant $fetchesSegmentConstant
*/
public function __construct(
CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant,
UpdatesSegmentConstantTax $updatesSegmentConstantTax,
UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee,
UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge,
UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax,
UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime,
UpdatesSegmentConstant $updatesSegmentConstant,
FetchesSegmentConstant $fetchesSegmentConstant
)
{
$this->canUpdateStandardSegmentConstant = $canUpdateStandardSegmentConstant;
$this->updatesSegmentConstantTax = $updatesSegmentConstantTax;
$this->updatesSegmentConstantBillingFee = $updatesSegmentConstantBillingFee;
$this->updatesSegmentConstantServiceCharge = $updatesSegmentConstantServiceCharge;
$this->updatesSegmentConstantBookingAmountMax = $updatesSegmentConstantBookingAmountMax;
$this->updatesSegmentConstantPaymentAttemptExpiryTime = $updatesSegmentConstantPaymentAttemptExpiryTime;
$this->updatesSegmentConstant = $updatesSegmentConstant;
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
}
@@ -105,63 +68,16 @@ class UpdateStandardSegmentConstantLogic extends AbstractControllerLogic
$segment_constant_query = $this->fetchesSegmentConstant->execute(['id' => $request->route('id')]);
if ($segment_constant_query->reference == 'TAX') {
$segment_constant_object = new SegmentConstantTaxObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$segment_constant_object = new SegmentConstantObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('detail')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantTax->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
$segment_constant_object = new SegmentConstantBillingFeeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantBillingFee->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
$segment_constant_object = new SegmentConstantServiceChargeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantServiceCharge->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value'),
$segment_constant_query->detail->currency_id
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantBookingAmountMax->execute($segment_constant_query, $segment_constant_object);
}
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
$segment_constant_query->segment_id,
$segment_constant_query->name,
$segment_constant_query->reference,
$segment_constant_query->detail->type,
$request->input('value')
);
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstantPaymentAttemptExpiryTime->execute($segment_constant_query, $segment_constant_object);
}
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
$segment_constant_query = $this->updatesSegmentConstant->execute($segment_constant_query, $segment_constant_object);
DB::commit();
@@ -1,100 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
use App\Classes\Interfaces\DataTransferObject;
class SegmentConstantBookingAmountMaxObject implements DataTransferObject
{
/** @var int|null */
private $segment_id;
/** @var string|null */
private $name;
/** @var string|null */
private $reference;
/** @var int */
private $type;
/** @var int */
private $value;
/** @var int */
private $currency_id;
/**
* SegmentConstantObject constructor.
* @param string|null $segment_id
* @param string|null $name
* @param string|null $reference
* @param string|null $type
* @param int|null $value
* @param int|null $currency_id
*/
public function __construct(
?int $segment_id,
?string $name,
?string $reference,
?string $type,
?int $value,
?int $currency_id
)
{
$this->segment_id = $segment_id;
$this->name = $name;
$this->reference = $reference;
$this->type = $type;
$this->value = $value;
$this->currency_id = $currency_id;
}
/**
* @return int
*/
public function getSegmentId(): ?int
{
return $this->segment_id;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @return string
*/
public function getReference(): ?string
{
return $this->reference;
}
/**
* @return string
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @return int
*/
public function getValue(): ?int
{
return $this->value;
}
/**
* @return int
*/
public function getCurrencyId(): ?int
{
return $this->currency_id;
}
}
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
use App\Classes\Interfaces\DataTransferObject;
class SegmentConstantBillingFeeObject implements DataTransferObject
class SegmentConstantObject implements DataTransferObject
{
/** @var int|null */
private $segment_id;
@@ -18,8 +18,8 @@ class SegmentConstantBillingFeeObject implements DataTransferObject
/** @var int */
private $type;
/** @var int */
private $value;
/** @var array */
private $detail;
/**
* SegmentConstantObject constructor.
@@ -27,21 +27,21 @@ class SegmentConstantBillingFeeObject implements DataTransferObject
* @param string|null $name
* @param string|null $reference
* @param string|null $type
* @param int|null $value
* @param array|null $detail
*/
public function __construct(
?int $segment_id,
?string $name,
?string $reference,
?string $type,
?int $value
?array $detail
)
{
$this->segment_id = $segment_id;
$this->name = $name;
$this->reference = $reference;
$this->type = $type;
$this->value = $value;
$this->detail = $detail;
}
/**
@@ -77,10 +77,10 @@ class SegmentConstantBillingFeeObject implements DataTransferObject
}
/**
* @return int
* @return array
*/
public function getValue(): ?int
public function getDetail(): ?array
{
return $this->value;
return $this->detail;
}
}
@@ -1,86 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
use App\Classes\Interfaces\DataTransferObject;
class SegmentConstantPaymentAttemptExpiryTimeObject implements DataTransferObject
{
/** @var int|null */
private $segment_id;
/** @var string|null */
private $name;
/** @var string|null */
private $reference;
/** @var int */
private $type;
/** @var int */
private $value;
/**
* SegmentConstantObject constructor.
* @param string|null $segment_id
* @param string|null $name
* @param string|null $reference
* @param string|null $type
* @param int|null $value
*/
public function __construct(
?int $segment_id,
?string $name,
?string $reference,
?string $type,
?int $value
)
{
$this->segment_id = $segment_id;
$this->name = $name;
$this->reference = $reference;
$this->type = $type;
$this->value = $value;
}
/**
* @return int
*/
public function getSegmentId(): ?int
{
return $this->segment_id;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @return string
*/
public function getReference(): ?string
{
return $this->reference;
}
/**
* @return string
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @return int
*/
public function getValue(): ?int
{
return $this->value;
}
}
@@ -1,86 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
use App\Classes\Interfaces\DataTransferObject;
class SegmentConstantServiceChargeObject implements DataTransferObject
{
/** @var int|null */
private $segment_id;
/** @var string|null */
private $name;
/** @var string|null */
private $reference;
/** @var int */
private $type;
/** @var int */
private $value;
/**
* SegmentConstantObject constructor.
* @param string|null $segment_id
* @param string|null $name
* @param string|null $reference
* @param string|null $type
* @param int|null $value
*/
public function __construct(
?int $segment_id,
?string $name,
?string $reference,
?string $type,
?int $value
)
{
$this->segment_id = $segment_id;
$this->name = $name;
$this->reference = $reference;
$this->type = $type;
$this->value = $value;
}
/**
* @return int
*/
public function getSegmentId(): ?int
{
return $this->segment_id;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @return string
*/
public function getReference(): ?string
{
return $this->reference;
}
/**
* @return string
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @return int
*/
public function getValue(): ?int
{
return $this->value;
}
}
@@ -1,86 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
use App\Classes\Interfaces\DataTransferObject;
class SegmentConstantTaxObject implements DataTransferObject
{
/** @var int|null */
private $segment_id;
/** @var string|null */
private $name;
/** @var string|null */
private $reference;
/** @var int */
private $type;
/** @var int */
private $value;
/**
* SegmentConstantObject constructor.
* @param string|null $segment_id
* @param string|null $name
* @param string|null $reference
* @param string|null $type
* @param int|null $value
*/
public function __construct(
?int $segment_id,
?string $name,
?string $reference,
?string $type,
?int $value
)
{
$this->segment_id = $segment_id;
$this->name = $name;
$this->reference = $reference;
$this->type = $type;
$this->value = $value;
}
/**
* @return int
*/
public function getSegmentId(): ?int
{
return $this->segment_id;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @return string
*/
public function getReference(): ?string
{
return $this->reference;
}
/**
* @return string
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @return int
*/
public function getValue(): ?int
{
return $this->value;
}
}
@@ -3,27 +3,24 @@
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
use App\Models\SegmentConstant;
use App\Models\Segment;
class CreatesSegmentConstantTax extends AbstractUpdateRecord
class CreatesSegmentConstant extends AbstractUpdateRecord
{
/**
* @param SegmentConstantTaxObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Segment $segment, SegmentConstantTaxObject $object)
public function execute(Segment $segment, SegmentConstantObject $object)
{
$model = new SegmentConstant();
$model->segment_id = $object->getSegmentId();
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
$model->detail = json_encode($object->getDetail());
return $this->handler($model);
}
@@ -1,30 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
use App\Models\SegmentConstant;
use App\Models\Segment;
class CreatesSegmentConstantBillingFee extends AbstractUpdateRecord
{
/**
* @param SegmentConstantBillingFeeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Segment $segment, SegmentConstantBillingFeeObject $object)
{
$model = new SegmentConstant();
$model->segment_id = $segment->id;
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
return $this->handler($model);
}
}
@@ -1,31 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
use App\Models\SegmentConstant;
use App\Models\Segment;
class CreatesSegmentConstantBookingAmountMax extends AbstractUpdateRecord
{
/**
* @param SegmentConstantBookingAmountMaxObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Segment $segment, SegmentConstantBookingAmountMaxObject $object)
{
$model = new SegmentConstant();
$model->segment_id = $segment->id;
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue(),
'currency_id' => $object->getCurrencyId()
]);
return $this->handler($model);
}
}
@@ -1,30 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttempExpiryTimeObject;
use App\Models\SegmentConstant;
use App\Models\Segment;
class CreatesSegmentConstantPaymentAttemptExpiryTime extends AbstractUpdateRecord
{
/**
* @param SegmentConstantPaymentAttempExpiryTimeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Segment $segment, SegmentConstantPaymentAttempExpiryTimeObject $object)
{
$model = new SegmentConstant();
$model->segment_id = $object->getSegmentId();
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue(),
]);
return $this->handler($model);
}
}
@@ -1,30 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
use App\Models\SegmentConstant;
use App\Models\Segment;
class CreatesSegmentConstantServiceCharge extends AbstractUpdateRecord
{
/**
* @param SegmentConstantServiceChargeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Segment $segment, SegmentConstantServiceChargeObject $object)
{
$model = new SegmentConstant();
$model->segment_id = $object->getSegmentId();
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
return $this->handler($model);
}
}
@@ -3,25 +3,22 @@
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
use App\Models\SegmentConstant;
class UpdatesSegmentConstantTax extends AbstractUpdateRecord
class UpdatesSegmentConstant extends AbstractUpdateRecord
{
/**
* @param SegmentConstantTaxObject $object
* @param SegmentConstantObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(SegmentConstant $model, SegmentConstantTaxObject $object)
public function execute(SegmentConstant $model, SegmentConstantObject $object)
{
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
$model->detail = json_encode($object->getDetail());
return $this->handler($model);
}
@@ -1,28 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
use App\Models\SegmentConstant;
class UpdatesSegmentConstantBillingFee extends AbstractUpdateRecord
{
/**
* @param SegmentConstantBillingFeeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(SegmentConstant $model, SegmentConstantBillingFeeObject $object)
{
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
return $this->handler($model);
}
}
@@ -1,29 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
use App\Models\SegmentConstant;
class UpdatesSegmentConstantBookingAmountMax extends AbstractUpdateRecord
{
/**
* @param SegmentConstantBookingAmountMaxObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(SegmentConstant $model, SegmentConstantBookingAmountMaxObject $object)
{
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue(),
'currency_id' => $object->getCurrencyId(),
]);
return $this->handler($model);
}
}
@@ -1,28 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
use App\Models\SegmentConstant;
class UpdatesSegmentConstantPaymentAttemptExpiryTime extends AbstractUpdateRecord
{
/**
* @param SegmentConstantPaymentAttemptExpiryTimeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(SegmentConstant $model, SegmentConstantPaymentAttemptExpiryTimeObject $object)
{
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
return $this->handler($model);
}
}
@@ -1,28 +0,0 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Services;
use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
use App\Models\SegmentConstant;
class UpdatesSegmentConstantServiceCharge extends AbstractUpdateRecord
{
/**
* @param SegmentConstantServiceChargeObject $object
* @return \Illuminate\Database\Eloquent\Model
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(SegmentConstant $model, SegmentConstantServiceChargeObject $object)
{
$model->name = $object->getName();
$model->reference = $object->getReference();
$model->detail = json_encode([
'type' => $object->getType(),
'value' => $object->getValue()
]);
return $this->handler($model);
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Classes\Modules\SegmentConstants\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentCompanyObject;
use App\Classes\Modules\SegmentConstants\Standards\Validators\SegmentConstantValidation;
class CanUpdateSegmentConstant extends AbstractRule
{
/** @var SegmentConstantValidation */
private $segmentConstantValidation;
/**
* CanCreateAddress constructor.
* @param SegmentConstantValidation $segmentConstantValidation
*/
public function __construct(SegmentConstantValidation $segmentConstantValidation)
{
$this->segmentConstantValidation = $segmentConstantValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
if (!\Auth::user()->can('view segment_constant')) {
return false;
}
return true;
}
/**
* @param SegmentConstantValidation $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->segmentConstantValidation->validate($object, 'PUT');
}
/**
* @param SegmentConstantValidation $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}
@@ -14,106 +14,28 @@ class SegmentConstantValidation extends AbstractValidation
*/
protected function data($object): array {
$this->reference = $object->getReference();
if ($this->reference == 'TAX') {
return [
'segment_id'=> $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'value' => $object->getValue()
];
}
elseif ($this->reference == 'BILLING_FEE') {
return [
'segment_id' => $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'value' => $object->getValue()
];
}
elseif ($this->reference == 'SERVICE_CHARGE') {
return [
'segment_id' => $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'value' => $object->getValue()
];
}
elseif ($this->reference == 'BOOKING_AMOUNT_MAX') {
return [
'segment_id' => $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'value' => $object->getValue(),
'currency_id' => $object->getCurrencyId()
];
}
elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
return [
'segment_id' => $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'value' => $object->getValue()
];
}
$data = [
'segment_id'=> $object->getSegmentId(),
'name' => $object->getName(),
'reference' => $object->getReference(),
'type' => $object->getType(),
'detail' => $object->getDetail()
];
return $data;
}
/**
* @return array
*/
protected function rules(?string $type = 'POST'): array {
if ($this->reference == 'TAX') {
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'value' => 'required'
];
}
elseif ($this->reference == 'BILLING_FEE') {
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'value' => 'required'
];
}
elseif ($this->reference == 'SERVICE_CHARGE') {
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'value' => 'required'
];
}
elseif ($this->reference == 'BOOKING_AMOUNT_MAX') {
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'value' => 'required',
'currency_id' => 'required'
];
}
elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'value' => 'required',
];
}
return [
'segment_id' => $type == 'POST' ? 'required' : '',
'name' => 'required',
'reference' => 'required',
'type' => 'required',
'detail' => 'required'
];
}
/**
-2
View File
@@ -21,8 +21,6 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
require __DIR__ . '/document.php';
require __DIR__ . '/segment.php';
require __DIR__ . '/segment_constant.php';
Route::group(['middleware' => 'valid.token'], function () {
require __DIR__ . '/crud.php';
+20 -1
View File
@@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Route;
Route::group(['namespace' => 'StandardSegments'], function () {
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'standard-segment'], function () {
Route::get('/list', 'ListStandardSegmentsController@list')->name('standard_segment.update');
Route::get('/list', 'ListStandardSegmentsController@list')->name('standard_segment.list');
});
});
});
@@ -18,4 +18,23 @@ Route::group(['namespace' => 'Segments'], function () {
Route::delete('/delete/{id}', 'DeleteSegmentController@delete')->name('segment.delete');
});
});
});
Route::group(['namespace' => 'StandardSegmentConstants'], function () {
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'standard-segment-constant'], function () {
Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
Route::put('/update/{id}', 'UpdateStandardSegmentConstantController@update')->name('standard_segment_constant.update');
});
});
});
Route::group(['namespace' => 'SegmentConstants'], function () {
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'segment-constant'], function () {
// Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
Route::post('/create', 'CreateSegmentConstantController@create')->name('segment_constant.create');
Route::put('/update/{id}', 'UpdateSegmentConstantController@update')->name('segment_constant.update');
});
});
});
-23
View File
@@ -1,23 +0,0 @@
<?php
use Illuminate\Support\Facades\Route;
Route::group(['namespace' => 'StandardSegmentConstants'], function () {
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'standard-segment-constant'], function () {
Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
Route::put('/update/{id}', 'UpdateStandardSegmentConstantController@update')->name('standard_segment_constant.update');
});
});
});
Route::group(['namespace' => 'SegmentConstants'], function () {
Route::group(['middleware' => 'valid.token'], function () {
Route::group(['prefix' => 'segment-constant'], function () {
// Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
Route::post('/create', 'CreateSegmentConstantController@create')->name('segment_constant.create');
Route::put('/update/{id}', 'UpdateSegmentConstantController@update')->name('segment_constant.update');
});
});
});