1 | <?php |
||
18 | class Ticket extends Model |
||
19 | { |
||
20 | use HasConfigModel; |
||
21 | |||
22 | protected $fillable = [ |
||
23 | 'subject', |
||
24 | 'priority', |
||
25 | 'state', |
||
26 | 'category_id', |
||
27 | ]; |
||
28 | |||
29 | public function getTable() |
||
33 | |||
34 | /** |
||
35 | * returns every user that had sent a message in the ticket |
||
36 | * |
||
37 | * @param false $ticketCreatorIncluded if the ticket user should be included |
||
38 | * |
||
39 | * @return Collection |
||
40 | */ |
||
41 | public function getRelatedUsers($ticketCreatorIncluded = false) |
||
50 | |||
51 | /** |
||
52 | * Gives every message |
||
53 | * |
||
54 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
55 | */ |
||
56 | public function messages() |
||
60 | |||
61 | /** |
||
62 | * Gets the creator of the ticket, |
||
63 | * can be null if the user has created ticket himself |
||
64 | * |
||
65 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|null |
||
66 | */ |
||
67 | public function opener() |
||
71 | |||
72 | /** |
||
73 | * The owner of the ticket |
||
74 | * |
||
75 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
76 | */ |
||
77 | public function user() |
||
81 | |||
82 | /** |
||
83 | * The category that the ticket belongs to |
||
84 | * |
||
85 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
86 | */ |
||
87 | public function category() |
||
91 | |||
92 | /** |
||
93 | * The ticket reference that the ticket binds to |
||
94 | * Can be null if the user hasnt selected any reference |
||
95 | * |
||
96 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
97 | */ |
||
98 | public function reference() |
||
102 | |||
103 | /** |
||
104 | * Gives the complete ticket activities |
||
105 | * |
||
106 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
107 | */ |
||
108 | public function activities() |
||
112 | |||
113 | /** |
||
114 | * Used for filtering the tickets by state |
||
115 | * |
||
116 | * @param $query |
||
117 | * @param $state |
||
118 | * |
||
119 | * @return mixed |
||
120 | */ |
||
121 | public function scopeState($query, $state) |
||
125 | |||
126 | /** |
||
127 | * Used for filtering the tickets by priority |
||
128 | * |
||
129 | * @param $query |
||
130 | * @param $priority |
||
131 | * |
||
132 | * @return mixed |
||
133 | */ |
||
134 | public function scopePriority($query, $priority) |
||
138 | } |
||
139 |