2022-01-16 23:54:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace common\services;
|
|
|
|
|
2023-01-18 15:30:38 +03:00
|
|
|
use common\models\ProjectTask;
|
2022-01-16 23:54:13 +03:00
|
|
|
|
|
|
|
class TaskService
|
|
|
|
{
|
|
|
|
public static function createTask($taskParams)
|
|
|
|
{
|
2023-01-18 15:30:38 +03:00
|
|
|
$task = new ProjectTask();
|
2022-01-16 23:54:13 +03:00
|
|
|
$task->load($taskParams, '');
|
|
|
|
$task->save();
|
|
|
|
return $task;
|
|
|
|
}
|
|
|
|
|
2023-01-18 15:30:38 +03:00
|
|
|
public static function getTask($task_id): ?ProjectTask
|
2022-01-16 23:54:13 +03:00
|
|
|
{
|
2023-01-18 15:30:38 +03:00
|
|
|
return ProjectTask::findOne($task_id);
|
2022-01-16 23:54:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTaskList($task_id): array
|
|
|
|
{
|
2023-01-18 15:30:38 +03:00
|
|
|
return ProjectTask::find()->asArray()->all();
|
2022-01-16 23:54:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTaskListByProject($project_id): array
|
|
|
|
{
|
2023-01-18 15:30:38 +03:00
|
|
|
return ProjectTask::find()->where(['project_id' => $project_id])->asArray()->all();
|
2022-01-16 23:54:13 +03:00
|
|
|
}
|
|
|
|
|
2023-04-25 01:32:15 +03:00
|
|
|
public static function getTaskListByUser($user_id): array
|
|
|
|
{
|
|
|
|
return ProjectTask::find()->where(['user_id' => $user_id])->all();
|
|
|
|
}
|
|
|
|
|
2023-01-18 15:30:38 +03:00
|
|
|
public static function updateTask($task_params): ?ProjectTask
|
2022-01-16 23:54:13 +03:00
|
|
|
{
|
2023-01-18 15:30:38 +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
|
|
|
|
{
|
2023-01-18 15:30:38 +03:00
|
|
|
return ProjectTask::find()->where(['id' => $task_id])->exists();
|
2022-01-16 23:54:13 +03:00
|
|
|
}
|
|
|
|
}
|