60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Task extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'id',
|
|
'name',
|
|
'description',
|
|
'parent_id',
|
|
'project_id',
|
|
'status_id',
|
|
'created_by_id',
|
|
];
|
|
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by_id');
|
|
}
|
|
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class);
|
|
}
|
|
|
|
public function status(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaskStatus::class);
|
|
}
|
|
|
|
public function labels(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Label::class);
|
|
}
|
|
|
|
public function department(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Department::class);
|
|
}
|
|
|
|
public function notes(): HasMany
|
|
{
|
|
return $this->hasMany('App\Models\Note', 'task_id');
|
|
}
|
|
|
|
public function subTasks(): HasMany
|
|
{
|
|
return $this->hasMany('App\Models\Task', 'parent_id');
|
|
}
|
|
}
|