NASER add task functions
This commit is contained in:
+19
-3
@@ -6,15 +6,16 @@ use Illuminate\Console\View\Components\Task;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
|
||||
class Tasks extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory,SoftDeletes;
|
||||
|
||||
protected $table = 'tasks';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'task_id',
|
||||
'title',
|
||||
@@ -65,6 +66,21 @@ class Tasks extends Model
|
||||
return $this->belogsTo(App::class);
|
||||
}
|
||||
|
||||
public function duration(){
|
||||
return $this->hasMany(TaskDuration::class, 'task_id', 'id');
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(TaskComment::class, 'task_id', 'id')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
public function userDurations($userId = null)
|
||||
{
|
||||
$userId = $userId ?: User::where('user_name', $_COOKIE['user_identity'])->first()->id; // پیشفرض: کاربر جاری
|
||||
return $this->taskDurations()->where('user_id', $userId);
|
||||
}
|
||||
|
||||
public function filterByState($tasks){
|
||||
$backlog = [];
|
||||
$todo = [];
|
||||
@@ -86,7 +102,7 @@ class Tasks extends Model
|
||||
'todo' => $todo,
|
||||
'inprogress' => $inprogress,
|
||||
'done' => $done,
|
||||
'count' => count($tasks),
|
||||
// 'count' => count($tasks),
|
||||
];
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user