1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fabrica\Models\Code; |
4
|
|
|
|
5
|
|
|
use Fabrica\Models\Code\Project; |
6
|
|
|
use Finder\Models\Reference; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
use StdClass; |
9
|
|
|
use Pedreiro\Models\Base; |
10
|
|
|
|
11
|
|
|
class Issue extends Base |
12
|
|
|
{ |
13
|
|
|
protected $organizationPerspective = true; |
14
|
|
|
|
15
|
|
|
protected $table = 'code_issues'; |
16
|
|
|
|
17
|
|
|
protected $action = false; |
18
|
|
|
|
19
|
|
|
protected $target = false; |
20
|
|
|
|
21
|
|
|
protected $worker = false; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The attributes that are mass assignable. |
25
|
|
|
* |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
protected $fillable = [ |
29
|
|
|
'name', |
30
|
|
|
'key_name', |
31
|
|
|
'slug', |
32
|
|
|
'url', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
public $formFields = [ |
36
|
|
|
['name' => 'title', 'label' => 'Title', 'type' => 'text'], |
37
|
|
|
['name' => 'slug', 'label' => 'Slug', 'type' => 'text'], |
38
|
|
|
['name' => 'body', 'label' => 'Enter your content here', 'type' => 'textarea'], |
39
|
|
|
['name' => 'publish_on', 'label' => 'Publish Date', 'type' => 'date'], |
40
|
|
|
['name' => 'published', 'label' => 'Published', 'type' => 'checkbox'], |
41
|
|
|
['name' => 'category_id', 'label' => 'Category', 'type' => 'select', 'relationship' => 'category'], |
42
|
|
|
['name' => 'tags', 'label' => 'Tags', 'type' => 'select_multiple', 'relationship' => 'tags'], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
public $indexFields = [ |
46
|
|
|
'title', |
47
|
|
|
'category_id', |
48
|
|
|
'published' |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
public $validationRules = [ |
52
|
|
|
'title' => 'required|max:255', |
53
|
|
|
'slug' => 'required|max:100', |
54
|
|
|
'body' => 'required', |
55
|
|
|
'publish_on' => 'date', |
56
|
|
|
'published' => 'boolean', |
57
|
|
|
'category_id' => 'required|int', |
58
|
|
|
]; |
59
|
|
|
|
60
|
|
|
public $validationMessages = [ |
61
|
|
|
'body.required' => "You need to fill in the post content." |
62
|
|
|
]; |
63
|
|
|
|
64
|
|
|
public $validationAttributes = [ |
65
|
|
|
'title' => 'Post title' |
66
|
|
|
]; |
67
|
|
|
|
68
|
|
|
public function project() |
69
|
|
|
{ |
70
|
|
|
return $this->belongsTo(Project::class, 'code_project_id', 'id'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function setField($fields, $issueKey) |
74
|
|
|
{ |
75
|
|
|
// @todo fazer aqui |
76
|
|
|
foreach ($fields as $fieldIdentify=>$result) { |
77
|
|
|
if (is_a($result, StdClass::class)) { |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if (Str::start($fieldIdentify, 'customfield')) { |
81
|
|
|
// @todo |
82
|
|
|
// dd($fieldIdentify, $result); $field = Field::firstOrCreate([ |
83
|
|
|
// 'code' => $fieldIdentify |
84
|
|
|
// ]); |
85
|
|
|
FieldValue::create( |
86
|
|
|
[ |
87
|
|
|
'value' => $fieldIdentify, |
88
|
|
|
'code_field_code' => $fieldIdentify, |
89
|
|
|
'code_issue_id' => $issueKey, |
90
|
|
|
] |
91
|
|
|
); |
92
|
|
|
} elseif ($fieldIdentify == 'summary') { |
93
|
|
|
$this->title = $result; |
94
|
|
|
} elseif ($fieldIdentify == 'description') { |
95
|
|
|
$this->description = $result; |
96
|
|
|
} elseif ($fieldIdentify == 'created') { |
97
|
|
|
$this->created_at = (string) $result; |
98
|
|
|
} elseif ($fieldIdentify == 'updated') { |
99
|
|
|
$this->updated_at = (string) $result; |
100
|
|
|
} elseif ($fieldIdentify == 'lastViewed') { |
101
|
|
|
|
102
|
|
|
} elseif ($fieldIdentify == 'resolutiondate') { |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
} elseif ($fieldIdentify == 'priority') { |
110
|
|
|
var_dump( |
|
|
|
|
111
|
|
|
[ |
112
|
|
|
'IssueModel priority', |
113
|
|
|
$fieldIdentify, |
114
|
|
|
$result |
115
|
|
|
] |
116
|
|
|
); |
117
|
|
|
} else { |
118
|
|
|
var_dump( |
119
|
|
|
[ |
120
|
|
|
'IssueModel', |
121
|
|
|
$fieldIdentify, |
122
|
|
|
$result |
123
|
|
|
] |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
$this->save(); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|