no message

This commit is contained in:
kuaifan
2021-06-03 11:41:24 +08:00
parent 1c856c34f9
commit 0b12ab55c0
13 changed files with 287 additions and 208 deletions

View File

@@ -25,6 +25,7 @@ use Carbon\Carbon;
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read int $file_num
* @property-read int $msg_num
* @property-read int $sub_num
* @property-read bool $overdue
* @property-read int $percent
* @property-read bool $today
@@ -55,6 +56,7 @@ class ProjectTask extends AbstractModel
protected $appends = [
'file_num',
'msg_num',
'sub_num',
'percent',
'today',
'overdue',
@@ -84,14 +86,35 @@ class ProjectTask extends AbstractModel
return $this->attributes['msg_num'];
}
/**
* 子任务数量
* @return int
*/
public function getSubNumAttribute()
{
if ($this->parent_id > 0) {
return 0;
}
if (!isset($this->attributes['sub_num'])) {
$this->attributes['sub_num'] = self::whereParentId($this->id)->count();
}
return $this->attributes['sub_num'];
}
/**
* 进度0-100
* @return int
*/
public function getPercentAttribute()
{
if ($this->parent_id > 0) {
return 0;
}
$builder = self::whereParentId($this->id);
$subTaskTotal = $builder->count();
if (!isset($this->attributes['sub_num'])) {
$this->attributes['sub_num'] = $builder->count();
}
$subTaskTotal = $this->attributes['sub_num'];
if ($subTaskTotal == 0) {
return $this->complete_at ? 1 : 0;
}