mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Vouchers\Services;
|
|
|
|
|
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
use App\Classes\Modules\Vouchers\DataTransferObjects\VoucherCampaignObject;
|
|
use App\Models\VoucherCampaign;
|
|
|
|
class CreatesVoucherCampaign extends AbstractUpdateRecord
|
|
{
|
|
/** @var CheckIfVoucherCampaignExists */
|
|
private $campaignExists;
|
|
|
|
/**
|
|
* CreatesVoucherCampaign constructor.
|
|
* @param CheckIfVoucherCampaignExists $campaignExists
|
|
*/
|
|
public function __construct(CheckIfVoucherCampaignExists $campaignExists)
|
|
{
|
|
$this->campaignExists = $campaignExists;
|
|
}
|
|
|
|
/**
|
|
* @param VoucherCampaignObject $object
|
|
* @return \Illuminate\Database\Eloquent\Model|null
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
*/
|
|
public function execute(VoucherCampaignObject $object) {
|
|
if(!$this->campaignExists->execute($object->getCampaignId()))
|
|
{
|
|
$model = new VoucherCampaign();
|
|
$model->campaign_id = $object->getCampaignId();
|
|
$model->name = $object->getName();
|
|
$model->description = $object->getDescription();
|
|
$model->limit_per_month = $object->getLimitPerMonth();
|
|
return $this->handler($model);
|
|
}
|
|
return null;
|
|
}
|
|
}
|