Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rexlManu committed Dec 13, 2020
1 parent 4b4d4bd commit 23fada1
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/Commands/AutoCloseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
7 changes: 7 additions & 0 deletions src/Events/TicketCloseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/Events/TicketMessageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/Events/TicketOpenEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/Helper/ReferenceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

namespace RexlManu\LaravelTickets\Helper;


/**
* Class ReferenceHelper
*
* Provides helper functions for the ticket reference
*
* @package RexlManu\LaravelTickets\Helper
*/
class ReferenceHelper
{

Expand Down
55 changes: 55 additions & 0 deletions src/Models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions src/Models/TicketActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/Models/TicketCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
22 changes: 22 additions & 0 deletions src/Models/TicketMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions src/Models/TicketReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions src/Models/TicketUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -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');
Expand Down
8 changes: 7 additions & 1 deletion src/Traits/HasConfigModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

namespace RexlManu\LaravelTickets\Traits;


/**
* Trait HasConfigModel
*
* Is used internal for using configuration elements
*
* @package RexlManu\LaravelTickets\Traits
*/
trait HasConfigModel
{

Expand Down
9 changes: 8 additions & 1 deletion src/Traits/HasTicketReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
7 changes: 7 additions & 0 deletions src/Traits/HasTickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down

0 comments on commit 23fada1

Please sign in to comment.