| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Models; |
| 4 |
use FluentBoards\App\Services\Constant; |
| 5 |
|
| 6 |
class TaskMeta extends Model |
| 7 |
{ |
| 8 |
protected $table = 'fbs_task_metas'; |
| 9 |
|
| 10 |
protected $guarded = ['id']; |
| 11 |
|
| 12 |
protected $fillable = [ |
| 13 |
'task_id', |
| 14 |
'key', |
| 15 |
'value' |
| 16 |
]; |
| 17 |
|
| 18 |
public function task() |
| 19 |
{ |
| 20 |
return $this->belongsTo(Task::class, 'task_id', 'id'); |
| 21 |
} |
| 22 |
|
| 23 |
public function setValueAttribute($value) |
| 24 |
{ |
| 25 |
$this->attributes['value'] = \maybe_serialize($value); |
| 26 |
} |
| 27 |
|
| 28 |
public function getValueAttribute($value) |
| 29 |
{ |
| 30 |
return \maybe_unserialize($value); |
| 31 |
} |
| 32 |
|
| 33 |
public function subtasks() |
| 34 |
{ |
| 35 |
return $this->belongsToMany( |
| 36 |
Task::class, |
| 37 |
'fbs_task_metas', |
| 38 |
'value', |
| 39 |
'task_id' |
| 40 |
)->where('key', Constant::SUBTASK_GROUP_CHILD); |
| 41 |
} |
| 42 |
} |
| 43 |
|