mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Milestones\Services;
|
|
|
|
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
|
use App\Models\Milestone;
|
|
use App\Models\MilestoneProgress;
|
|
|
|
class CreatesMilestoneProgress extends AbstractUpdateRelationshipRecord
|
|
{
|
|
/** @var CheckIfMilestoneProgressExists */
|
|
private $isMilestoneProgressExists;
|
|
|
|
/**
|
|
* CreatesMilestoneProgress constructor.
|
|
* @param CheckIfMilestoneProgressExists $isMilestoneProgressExists
|
|
*/
|
|
public function __construct(CheckIfMilestoneProgressExists $isMilestoneProgressExists)
|
|
{
|
|
$this->isMilestoneProgressExists = $isMilestoneProgressExists;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Milestone $milestone
|
|
* @param string $userId
|
|
* @return \Illuminate\Database\Eloquent\Model|null
|
|
*/
|
|
public function execute(Milestone $milestone, string $userId) {
|
|
if(!$this->isMilestoneProgressExists->execute($userId, $milestone->id))
|
|
{
|
|
$model = new MilestoneProgress();
|
|
$model->user_id = $userId;
|
|
|
|
return $this->handler($milestone->progress(), $model);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|