From 23fada12748e0b59b40aae482ec9ab4c278b621f Mon Sep 17 00:00:00 2001 From: Emmanuel Lampe Date: Mon, 14 Dec 2020 00:21:42 +0100 Subject: [PATCH] Added docs --- src/Commands/AutoCloseCommand.php | 8 +++++ src/Events/TicketCloseEvent.php | 7 ++++ src/Events/TicketMessageEvent.php | 7 ++++ src/Events/TicketOpenEvent.php | 7 ++++ src/Helper/ReferenceHelper.php | 8 ++++- src/Models/Ticket.php | 55 +++++++++++++++++++++++++++++++ src/Models/TicketActivity.php | 17 ++++++++++ src/Models/TicketCategory.php | 7 ++++ src/Models/TicketMessage.php | 22 +++++++++++++ src/Models/TicketReference.php | 17 ++++++++++ src/Models/TicketUpload.php | 12 +++++++ src/Traits/HasConfigModel.php | 8 ++++- src/Traits/HasTicketReference.php | 9 ++++- src/Traits/HasTickets.php | 7 ++++ 14 files changed, 188 insertions(+), 3 deletions(-) diff --git a/src/Commands/AutoCloseCommand.php b/src/Commands/AutoCloseCommand.php index a71939b..9dc42cb 100644 --- a/src/Commands/AutoCloseCommand.php +++ b/src/Commands/AutoCloseCommand.php @@ -6,6 +6,14 @@ use Illuminate\Console\Command; use RexlManu\LaravelTickets\Models\Ticket; +/** + * Class AutoCloseCommand + * + * The command checks if a ticket is unanswered a specific time, + * that is in the configuration defined and then close it + * + * @package RexlManu\LaravelTickets\Commands + */ class AutoCloseCommand extends Command { /** diff --git a/src/Events/TicketCloseEvent.php b/src/Events/TicketCloseEvent.php index a4dea21..04d7247 100644 --- a/src/Events/TicketCloseEvent.php +++ b/src/Events/TicketCloseEvent.php @@ -13,6 +13,13 @@ use Illuminate\Queue\SerializesModels; use RexlManu\LaravelTickets\Models\Ticket; +/** + * Class TicketCloseEvent + * + * Fired when a ticket gets closed + * + * @package RexlManu\LaravelTickets\Events + */ class TicketCloseEvent { use Dispatchable, InteractsWithSockets, SerializesModels; diff --git a/src/Events/TicketMessageEvent.php b/src/Events/TicketMessageEvent.php index 2fb2aa9..5ebd1b1 100644 --- a/src/Events/TicketMessageEvent.php +++ b/src/Events/TicketMessageEvent.php @@ -14,6 +14,13 @@ use RexlManu\LaravelTickets\Models\Ticket; use RexlManu\LaravelTickets\Models\TicketMessage; +/** + * Class TicketMessageEvent + * + * Fired when a ticket gets answered by a user + * + * @package RexlManu\LaravelTickets\Events + */ class TicketMessageEvent { use Dispatchable, InteractsWithSockets, SerializesModels; diff --git a/src/Events/TicketOpenEvent.php b/src/Events/TicketOpenEvent.php index cb60c5d..84803df 100644 --- a/src/Events/TicketOpenEvent.php +++ b/src/Events/TicketOpenEvent.php @@ -13,6 +13,13 @@ use Illuminate\Queue\SerializesModels; use RexlManu\LaravelTickets\Models\Ticket; +/** + * Class TicketOpenEvent + * + * Fired when a ticket is created + * + * @package RexlManu\LaravelTickets\Events + */ class TicketOpenEvent { use Dispatchable, InteractsWithSockets, SerializesModels; diff --git a/src/Helper/ReferenceHelper.php b/src/Helper/ReferenceHelper.php index 46deb5f..e3ddd5e 100644 --- a/src/Helper/ReferenceHelper.php +++ b/src/Helper/ReferenceHelper.php @@ -3,7 +3,13 @@ namespace RexlManu\LaravelTickets\Helper; - +/** + * Class ReferenceHelper + * + * Provides helper functions for the ticket reference + * + * @package RexlManu\LaravelTickets\Helper + */ class ReferenceHelper { diff --git a/src/Models/Ticket.php b/src/Models/Ticket.php index 79cc46e..85d5dfa 100644 --- a/src/Models/Ticket.php +++ b/src/Models/Ticket.php @@ -8,6 +8,13 @@ use Illuminate\Support\Collection; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class Ticket + * + * The main data model for the ticket system + * + * @package RexlManu\LaravelTickets\Models + */ class Ticket extends Model { use HasConfigModel; @@ -41,41 +48,89 @@ public function getRelatedUsers($ticketCreatorIncluded = false) ->values(); } + /** + * Gives every message + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function messages() { return $this->hasMany(TicketMessage::class); } + /** + * Gets the creator of the ticket, + * can be null if the user has created ticket himself + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|null + */ public function opener() { return $this->belongsTo(config('laravel-tickets.user')); } + /** + * The owner of the ticket + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function user() { return $this->belongsTo(config('laravel-tickets.user')); } + /** + * The category that the ticket belongs to + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function category() { return $this->belongsTo(TicketCategory::class); } + /** + * The ticket reference that the ticket binds to + * Can be null if the user hasnt selected any reference + * + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ public function reference() { return $this->hasOne(TicketReference::class); } + /** + * Gives the complete ticket activities + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function activities() { return $this->hasMany(TicketActivity::class); } + /** + * Used for filtering the tickets by state + * + * @param $query + * @param $state + * + * @return mixed + */ public function scopeState($query, $state) { return $query->whereIn('state', is_string($state) ? [ $state ] : $state); } + /** + * Used for filtering the tickets by priority + * + * @param $query + * @param $priority + * + * @return mixed + */ public function scopePriority($query, $priority) { return $query->where('priority', $priority); diff --git a/src/Models/TicketActivity.php b/src/Models/TicketActivity.php index 460b23e..1df6ee1 100644 --- a/src/Models/TicketActivity.php +++ b/src/Models/TicketActivity.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Model; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class TicketActivity + * + * This data model is used to log every action that was fired by a interaction + * + * @package RexlManu\LaravelTickets\Models + */ class TicketActivity extends Model { use HasConfigModel; @@ -15,6 +22,11 @@ class TicketActivity extends Model 'type' ]; + /** + * Gives the ticket that the activity belongs to + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function ticket() { return $this->belongsTo(Ticket::class, 'ticket_id'); @@ -25,6 +37,11 @@ public function getTable() return config('laravel-tickets.database.ticket-activities-table'); } + /** + * Gives the target, can be ticket, user or message + * + * @return \Illuminate\Database\Eloquent\Relations\MorphTo + */ public function targetable() { return $this->morphTo(); diff --git a/src/Models/TicketCategory.php b/src/Models/TicketCategory.php index 4153dd7..886f598 100644 --- a/src/Models/TicketCategory.php +++ b/src/Models/TicketCategory.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Model; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class TicketCategory + * + * Used for declaring a ticket to a specific topic + * + * @package RexlManu\LaravelTickets\Models + */ class TicketCategory extends Model { diff --git a/src/Models/TicketMessage.php b/src/Models/TicketMessage.php index bd45b00..1554a22 100644 --- a/src/Models/TicketMessage.php +++ b/src/Models/TicketMessage.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Model; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class TicketMessage + * + * The message that a user sent + * + * @package RexlManu\LaravelTickets\Models + */ class TicketMessage extends Model { @@ -21,16 +28,31 @@ public function getTable() return config('laravel-tickets.database.ticket-messages-table'); } + /** + * Gives the ticket that belongs to it + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function ticket() { return $this->belongsTo(Ticket::class, 'ticket_id'); } + /** + * Gives the creator of the message + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function user() { return $this->belongsTo(config('laravel-tickets.user')); } + /** + * Gives all uploads that a made with the message + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ public function uploads() { return $this->hasMany(TicketUpload::class); diff --git a/src/Models/TicketReference.php b/src/Models/TicketReference.php index 8a06160..4f182b5 100644 --- a/src/Models/TicketReference.php +++ b/src/Models/TicketReference.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Model; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class TicketReference + * + * Used to reference a specific model to a ticket + * + * @package RexlManu\LaravelTickets\Models + */ class TicketReference extends Model { @@ -17,11 +24,21 @@ public function getTable() return config('laravel-tickets.database.ticket-references-table'); } + /** + * Gives the ticket that belongs to it + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function ticket() { return $this->belongsTo(Ticket::class); } + /** + * Gives the model that is declared as reference + * + * @return \Illuminate\Database\Eloquent\Relations\MorphTo + */ public function referenceable() { return $this->morphTo(); diff --git a/src/Models/TicketUpload.php b/src/Models/TicketUpload.php index d556329..baab45c 100644 --- a/src/Models/TicketUpload.php +++ b/src/Models/TicketUpload.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Model; use RexlManu\LaravelTickets\Traits\HasConfigModel; +/** + * Class TicketUpload + * + * When a user sent a message with a file, the file gets attached to the ticket message + * + * @package RexlManu\LaravelTickets\Models + */ class TicketUpload extends Model { @@ -21,6 +28,11 @@ public function getTable() return config('laravel-tickets.database.ticket-uploads-table'); } + /** + * The message where the upload is attached to it + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ public function message() { return $this->belongsTo(TicketMessage::class, 'ticket_message_id'); diff --git a/src/Traits/HasConfigModel.php b/src/Traits/HasConfigModel.php index 78633c0..d23bbed 100644 --- a/src/Traits/HasConfigModel.php +++ b/src/Traits/HasConfigModel.php @@ -3,7 +3,13 @@ namespace RexlManu\LaravelTickets\Traits; - +/** + * Trait HasConfigModel + * + * Is used internal for using configuration elements + * + * @package RexlManu\LaravelTickets\Traits + */ trait HasConfigModel { diff --git a/src/Traits/HasTicketReference.php b/src/Traits/HasTicketReference.php index fc4f0af..de9917f 100644 --- a/src/Traits/HasTicketReference.php +++ b/src/Traits/HasTicketReference.php @@ -3,7 +3,14 @@ namespace RexlManu\LaravelTickets\Traits; - +/** + * Trait HasTicketReference + * + * For ticket references, when used on a model, + * the model also needs to be registered in the configuration + * + * @package RexlManu\LaravelTickets\Traits + */ trait HasTicketReference { diff --git a/src/Traits/HasTickets.php b/src/Traits/HasTickets.php index 7cbfb16..ab45805 100644 --- a/src/Traits/HasTickets.php +++ b/src/Traits/HasTickets.php @@ -7,6 +7,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use RexlManu\LaravelTickets\Models\Ticket; +/** + * Trait HasTickets + * + * Extends the user model with functions + * + * @package RexlManu\LaravelTickets\Traits + */ trait HasTickets {