PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.2.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.2.0
2.2.0 2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 All 43 releases
fluent-boards / app / Models / CustomField.php

CustomField.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 2.2.0, at app/Models/CustomField.php

45 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Models;
4
5 use FluentBoards\App\Models\Board;
6 use FluentBoards\App\Models\BoardTerm;
7 use FluentBoards\App\Models\Task;
8 use FluentBoards\Framework\Database\Orm\Builder;
9 use FluentBoards\App\Services\Constant;
10
11 /** Store custom-field data so native imports do not require the Pro addon. */
12 class CustomField extends BoardTerm
13 {
14 /** Scope custom fields to their shared board-term type. */
15 public static function boot()
16 {
17 parent::boot();
18 static::creating(function ($model) {
19 $model->type = $model->type ?: Constant::BOARD_TERM_CUSTOM_FIELD;
20 });
21
22 static::addGlobalScope('type', function (Builder $builder) {
23 $builder->where('type', '=', Constant::BOARD_TERM_CUSTOM_FIELD);
24 });
25 }
26
27 /** Return tasks using this custom field. */
28 public function tasks()
29 {
30 return $this->belongsToMany(
31 Task::class,
32 'fbs_relations',
33 'foreign_id',
34 'object_id'
35 )->withTimestamps()
36 ->wherePivot('object_type', Constant::TASK_CUSTOM_FIELD)
37 ->withPivot('settings', 'preferences');
38 }
39
40 /** Return the board that owns this field. */
41 public function board()
42 {
43 return $this->belongsTo(Board::class, 'board_id', 'id');
44 }
45 }