1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sfneal\Tracking\Models\Traits; |
4
|
|
|
|
5
|
|
|
use Domain\Plans\Models\Plan; |
|
|
|
|
6
|
|
|
use Domain\Plans\Models\PlanManagement; |
|
|
|
|
7
|
|
|
use Domain\Projects\Models\Project; |
|
|
|
|
8
|
|
|
use Domain\Tasks\Models\Task; |
|
|
|
|
9
|
|
|
use Domain\Tasks\Models\TaskRecord; |
|
|
|
|
10
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
11
|
|
|
|
12
|
|
|
// todo: probably move back to project |
13
|
|
|
trait TrackingRelationships |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Retrieve the TrackActivity instances Plan model if one exists. |
17
|
|
|
* |
18
|
|
|
* @return mixed|null |
19
|
|
|
*/ |
20
|
|
|
public function model() |
21
|
|
|
{ |
22
|
|
|
// Plan |
23
|
|
|
if ($this->model_table == 'plan') { |
24
|
|
|
return $this->plan; |
25
|
|
|
} elseif (inString($this->model_table, 'plan_management')) { |
26
|
|
|
// Return Plan model if it exists |
27
|
|
|
if ($this->planManagement->plan) { |
28
|
|
|
return $this->planManagement->plan; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// Otherwise return the Project model |
32
|
|
|
else { |
33
|
|
|
return $this->planManagement->project; |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// Project |
38
|
|
|
elseif ($this->model_table == 'project') { |
39
|
|
|
return $this->project; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
// Task |
43
|
|
|
elseif ($this->model_table == 'task_record' && $this->taskRecord && $this->taskRecord->task && $this->taskRecord->task->project) { |
44
|
|
|
return $this->taskRecord->task->project; |
45
|
|
|
} elseif ($this->model_table == 'task' && $this->task && $this->task->project) { |
46
|
|
|
return $this->task->project; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return null; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Retrieve a route for this model. |
54
|
|
|
* |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function modelRoute() |
58
|
|
|
{ |
59
|
|
|
// Plan |
60
|
|
|
if ($this->model() instanceof Plan) { |
61
|
|
|
return route('plans.plan.show', ['plan'=>$this->model()->getKey(), 'modal'=>1]); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// Project |
65
|
|
|
elseif ($this->model() instanceof Project) { |
66
|
|
|
return route('projects.show', ['project'=>$this->model()->getKey()]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Retrieve the link class. |
72
|
|
|
* |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function linkClass(): string |
76
|
|
|
{ |
77
|
|
|
if ($this->model() instanceof Plan) { |
78
|
|
|
return 'modal-link'; |
79
|
|
|
} else { |
80
|
|
|
return ''; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Plan relationship. |
86
|
|
|
* |
87
|
|
|
* @return BelongsTo |
88
|
|
|
*/ |
89
|
|
|
public function plan() |
90
|
|
|
{ |
91
|
|
|
return $this->belongsTo(Plan::class, 'model_key', 'plan_id'); |
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Plan management relationship. |
96
|
|
|
* |
97
|
|
|
* @return BelongsTo |
98
|
|
|
*/ |
99
|
|
|
public function planManagement() |
100
|
|
|
{ |
101
|
|
|
return $this->belongsTo(PlanManagement::class, 'model_key', 'project_id'); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Project relationship. |
106
|
|
|
* |
107
|
|
|
* @return BelongsTo |
108
|
|
|
*/ |
109
|
|
|
public function project() |
110
|
|
|
{ |
111
|
|
|
return $this->belongsTo(Project::class, 'model_key', 'project_id'); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Task relationship. |
116
|
|
|
* |
117
|
|
|
* @return BelongsTo |
118
|
|
|
*/ |
119
|
|
|
public function task() |
120
|
|
|
{ |
121
|
|
|
return $this->belongsTo(Task::class, 'model_key', 'task_id'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Task relationship. |
126
|
|
|
* |
127
|
|
|
* @return BelongsTo |
128
|
|
|
*/ |
129
|
|
|
public function taskRecord() |
130
|
|
|
{ |
131
|
|
|
return $this->belongsTo(TaskRecord::class, 'model_key', 'record_id'); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths