guild/common/services/TaskService.php

46 lines
1.0 KiB
PHP
Raw Normal View History

2022-01-16 23:54:13 +03:00
<?php
namespace common\services;
use common\models\ProjectTask;
2022-01-16 23:54:13 +03:00
class TaskService
{
public static function createTask($taskParams)
{
$task = new ProjectTask();
2022-01-16 23:54:13 +03:00
$task->load($taskParams, '');
$task->save();
return $task;
}
public static function getTask($task_id): ?ProjectTask
2022-01-16 23:54:13 +03:00
{
return ProjectTask::findOne($task_id);
2022-01-16 23:54:13 +03:00
}
public static function getTaskList($task_id): array
{
return ProjectTask::find()->asArray()->all();
2022-01-16 23:54:13 +03:00
}
public static function getTaskListByProject($project_id): array
{
return ProjectTask::find()->where(['project_id' => $project_id])->asArray()->all();
2022-01-16 23:54:13 +03:00
}
public static function updateTask($task_params): ?ProjectTask
2022-01-16 23:54:13 +03:00
{
$modelTask = ProjectTask::findOne($task_params['task_id']);
2022-01-16 23:54:13 +03:00
$modelTask->load($task_params, '');
$modelTask->save();
return $modelTask;
}
public static function taskExists($task_id): bool
{
return ProjectTask::find()->where(['id' => $task_id])->exists();
2022-01-16 23:54:13 +03:00
}
}