mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
update honey trap
This commit is contained in:
@@ -64,9 +64,21 @@ class AssignCompanyToSegmentLogic extends AbstractControllerLogic
|
||||
$this->assignCompanyToSegmentProcessor->execute($company, $request->input('segment_id'));
|
||||
|
||||
if (env('HONEY_TRAP_SEGMENT_ID') && env('HONEY_TRAP_SEGMENT_ID') == $request->input('segment_id')) {
|
||||
|
||||
// todo-new
|
||||
// if (isset($request->input('ending_on')) && $request->input('ending_on') <= Carbon::now()) {
|
||||
// return error
|
||||
// }
|
||||
|
||||
// todo-new
|
||||
// if (count($company->seasonalSegments)) {
|
||||
// return error
|
||||
// }
|
||||
|
||||
|
||||
$start_date = $request->input('starting_on') ? $request->input('starting_on') : Carbon::now();
|
||||
$seasonalSegmentObject = new SeasonalSegmentObject($request->route('id'), $request->input('segment_id'), $start_date, $request->input('ending_on'));
|
||||
// $seasonalSegmentObject = new SeasonalSegmentObject((int)$request->route('id'), $request->input('segment_id'), '01-01-2022', '01-01-2022');
|
||||
|
||||
$seasonalSegmentObject = new SeasonalSegmentObject($company->id, $request->input('segment_id'), $start_date, $request->input('ending_on') ?? null);
|
||||
|
||||
$this->createsSeasonalSegment->execute($seasonalSegmentObject);
|
||||
}
|
||||
|
||||
@@ -53,10 +53,13 @@ class RemoveCompanyFromSegmentLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
if (env('HONEY_TRAP_SEGMENT_ID') && env('HONEY_TRAP_SEGMENT_ID') == $request->route('segment_id')) {
|
||||
$company->seasonalSegments->first()->delete();
|
||||
}
|
||||
|
||||
$this->removesCompanyFromSegment->execute($company, $segment);
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ class SeasonalSegmentObject implements DataTransferObject
|
||||
* @param string $starting_on
|
||||
* @param string $ending_on
|
||||
*/
|
||||
public function __construct(int $companyId, int $segmentId, string $starting_on, string $ending_on, ?int $status = ApprovalStatus::APPROVED)
|
||||
public function __construct(int $companyId, int $segmentId, string $starting_on, ?string $ending_on = null, ?int $status = ApprovalStatus::APPROVED)
|
||||
{
|
||||
$this->$companyId = $companyId;
|
||||
$this->companyId = $companyId;
|
||||
$this->segmentId = $segmentId;
|
||||
$this->starting_on = $starting_on;
|
||||
$this->ending_on = $ending_on;
|
||||
@@ -67,7 +67,7 @@ class SeasonalSegmentObject implements DataTransferObject
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEndingOn(): string
|
||||
public function getEndingOn(): ?string
|
||||
{
|
||||
return $this->ending_on;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class CreatesSeasonalSegment extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(SeasonalSegmentObject $object) {
|
||||
$model = new SeasonalSegment();
|
||||
$model->company_id = $object->getSegmentId();
|
||||
$model->company_id = $object->getCompanyId();
|
||||
$model->segment_id = $object->getSegmentId();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
Reference in New Issue
Block a user