Files
water-back/modules/Task/Models/User.php
2023-01-12 14:47:38 +08:00

42 lines
885 B
PHP

<?php
namespace Modules\Task\Models;
use App\Models\Model;
use App\Traits\HasStatus;
use Illuminate\Support\Facades\Cache;
use Modules\Task\Models\Traits\BelongsToTask;
use Modules\User\Traits\BelongsToUser;
class User extends Model
{
use BelongsToUser, BelongsToTask, HasStatus;
protected $table = 'task_users';
const STATUS_INTI = 0;
const STATUS_FINISH = 1;
public array $status_map = [
self::STATUS_INTI => '进行中',
self::STATUS_FINISH => '完成',
];
/**
* Notes: 增加任务数
*
* @Author: 玄尘
* @Date: 2022/10/20 11:10
* @param int $step
*/
public function incrementTotal(int $step = 1)
{
if ($this->task->key == 'steps') {
$this->total = $step;
$this->save();
} else {
$this->increment('total', $step);
}
}
}