Skip to content

Commit 23fada1

Browse files
committed
Added docs
1 parent 4b4d4bd commit 23fada1

14 files changed

+188
-3
lines changed

src/Commands/AutoCloseCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
use Illuminate\Console\Command;
77
use RexlManu\LaravelTickets\Models\Ticket;
88

9+
/**
10+
* Class AutoCloseCommand
11+
*
12+
* The command checks if a ticket is unanswered a specific time,
13+
* that is in the configuration defined and then close it
14+
*
15+
* @package RexlManu\LaravelTickets\Commands
16+
*/
917
class AutoCloseCommand extends Command
1018
{
1119
/**

src/Events/TicketCloseEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
use Illuminate\Queue\SerializesModels;
1414
use RexlManu\LaravelTickets\Models\Ticket;
1515

16+
/**
17+
* Class TicketCloseEvent
18+
*
19+
* Fired when a ticket gets closed
20+
*
21+
* @package RexlManu\LaravelTickets\Events
22+
*/
1623
class TicketCloseEvent
1724
{
1825
use Dispatchable, InteractsWithSockets, SerializesModels;

src/Events/TicketMessageEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
use RexlManu\LaravelTickets\Models\Ticket;
1515
use RexlManu\LaravelTickets\Models\TicketMessage;
1616

17+
/**
18+
* Class TicketMessageEvent
19+
*
20+
* Fired when a ticket gets answered by a user
21+
*
22+
* @package RexlManu\LaravelTickets\Events
23+
*/
1724
class TicketMessageEvent
1825
{
1926
use Dispatchable, InteractsWithSockets, SerializesModels;

src/Events/TicketOpenEvent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
use Illuminate\Queue\SerializesModels;
1414
use RexlManu\LaravelTickets\Models\Ticket;
1515

16+
/**
17+
* Class TicketOpenEvent
18+
*
19+
* Fired when a ticket is created
20+
*
21+
* @package RexlManu\LaravelTickets\Events
22+
*/
1623
class TicketOpenEvent
1724
{
1825
use Dispatchable, InteractsWithSockets, SerializesModels;

src/Helper/ReferenceHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33

44
namespace RexlManu\LaravelTickets\Helper;
55

6-
6+
/**
7+
* Class ReferenceHelper
8+
*
9+
* Provides helper functions for the ticket reference
10+
*
11+
* @package RexlManu\LaravelTickets\Helper
12+
*/
713
class ReferenceHelper
814
{
915

src/Models/Ticket.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
use Illuminate\Support\Collection;
99
use RexlManu\LaravelTickets\Traits\HasConfigModel;
1010

11+
/**
12+
* Class Ticket
13+
*
14+
* The main data model for the ticket system
15+
*
16+
* @package RexlManu\LaravelTickets\Models
17+
*/
1118
class Ticket extends Model
1219
{
1320
use HasConfigModel;
@@ -41,41 +48,89 @@ public function getRelatedUsers($ticketCreatorIncluded = false)
4148
->values();
4249
}
4350

51+
/**
52+
* Gives every message
53+
*
54+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
55+
*/
4456
public function messages()
4557
{
4658
return $this->hasMany(TicketMessage::class);
4759
}
4860

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+
*/
4967
public function opener()
5068
{
5169
return $this->belongsTo(config('laravel-tickets.user'));
5270
}
5371

72+
/**
73+
* The owner of the ticket
74+
*
75+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
76+
*/
5477
public function user()
5578
{
5679
return $this->belongsTo(config('laravel-tickets.user'));
5780
}
5881

82+
/**
83+
* The category that the ticket belongs to
84+
*
85+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
86+
*/
5987
public function category()
6088
{
6189
return $this->belongsTo(TicketCategory::class);
6290
}
6391

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+
*/
6498
public function reference()
6599
{
66100
return $this->hasOne(TicketReference::class);
67101
}
68102

103+
/**
104+
* Gives the complete ticket activities
105+
*
106+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
107+
*/
69108
public function activities()
70109
{
71110
return $this->hasMany(TicketActivity::class);
72111
}
73112

113+
/**
114+
* Used for filtering the tickets by state
115+
*
116+
* @param $query
117+
* @param $state
118+
*
119+
* @return mixed
120+
*/
74121
public function scopeState($query, $state)
75122
{
76123
return $query->whereIn('state', is_string($state) ? [ $state ] : $state);
77124
}
78125

126+
/**
127+
* Used for filtering the tickets by priority
128+
*
129+
* @param $query
130+
* @param $priority
131+
*
132+
* @return mixed
133+
*/
79134
public function scopePriority($query, $priority)
80135
{
81136
return $query->where('priority', $priority);

src/Models/TicketActivity.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
use Illuminate\Database\Eloquent\Model;
88
use RexlManu\LaravelTickets\Traits\HasConfigModel;
99

10+
/**
11+
* Class TicketActivity
12+
*
13+
* This data model is used to log every action that was fired by a interaction
14+
*
15+
* @package RexlManu\LaravelTickets\Models
16+
*/
1017
class TicketActivity extends Model
1118
{
1219
use HasConfigModel;
@@ -15,6 +22,11 @@ class TicketActivity extends Model
1522
'type'
1623
];
1724

25+
/**
26+
* Gives the ticket that the activity belongs to
27+
*
28+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
29+
*/
1830
public function ticket()
1931
{
2032
return $this->belongsTo(Ticket::class, 'ticket_id');
@@ -25,6 +37,11 @@ public function getTable()
2537
return config('laravel-tickets.database.ticket-activities-table');
2638
}
2739

40+
/**
41+
* Gives the target, can be ticket, user or message
42+
*
43+
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
44+
*/
2845
public function targetable()
2946
{
3047
return $this->morphTo();

src/Models/TicketCategory.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
use Illuminate\Database\Eloquent\Model;
88
use RexlManu\LaravelTickets\Traits\HasConfigModel;
99

10+
/**
11+
* Class TicketCategory
12+
*
13+
* Used for declaring a ticket to a specific topic
14+
*
15+
* @package RexlManu\LaravelTickets\Models
16+
*/
1017
class TicketCategory extends Model
1118
{
1219

src/Models/TicketMessage.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
use Illuminate\Database\Eloquent\Model;
88
use RexlManu\LaravelTickets\Traits\HasConfigModel;
99

10+
/**
11+
* Class TicketMessage
12+
*
13+
* The message that a user sent
14+
*
15+
* @package RexlManu\LaravelTickets\Models
16+
*/
1017
class TicketMessage extends Model
1118
{
1219

@@ -21,16 +28,31 @@ public function getTable()
2128
return config('laravel-tickets.database.ticket-messages-table');
2229
}
2330

31+
/**
32+
* Gives the ticket that belongs to it
33+
*
34+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
35+
*/
2436
public function ticket()
2537
{
2638
return $this->belongsTo(Ticket::class, 'ticket_id');
2739
}
2840

41+
/**
42+
* Gives the creator of the message
43+
*
44+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
45+
*/
2946
public function user()
3047
{
3148
return $this->belongsTo(config('laravel-tickets.user'));
3249
}
3350

51+
/**
52+
* Gives all uploads that a made with the message
53+
*
54+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
55+
*/
3456
public function uploads()
3557
{
3658
return $this->hasMany(TicketUpload::class);

src/Models/TicketReference.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
use Illuminate\Database\Eloquent\Model;
88
use RexlManu\LaravelTickets\Traits\HasConfigModel;
99

10+
/**
11+
* Class TicketReference
12+
*
13+
* Used to reference a specific model to a ticket
14+
*
15+
* @package RexlManu\LaravelTickets\Models
16+
*/
1017
class TicketReference extends Model
1118
{
1219

@@ -17,11 +24,21 @@ public function getTable()
1724
return config('laravel-tickets.database.ticket-references-table');
1825
}
1926

27+
/**
28+
* Gives the ticket that belongs to it
29+
*
30+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
31+
*/
2032
public function ticket()
2133
{
2234
return $this->belongsTo(Ticket::class);
2335
}
2436

37+
/**
38+
* Gives the model that is declared as reference
39+
*
40+
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
41+
*/
2542
public function referenceable()
2643
{
2744
return $this->morphTo();

0 commit comments

Comments
 (0)