PHPackages                             shamazingg/laravel-ticket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shamazingg/laravel-ticket

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shamazingg/laravel-ticket
=========================

Laravel Ticket System, to help you manage your tickets eaisly

0622PHP

Since Oct 13Pushed 3y agoCompare

[ Source](https://github.com/ShamazinGG/laravel-ticket)[ Packagist](https://packagist.org/packages/shamazingg/laravel-ticket)[ RSS](/packages/shamazingg-laravel-ticket/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![Laravisit Logo](art/logo.png)](art/logo.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3dad83ec5088b807629bd90d96664a0e24d93219e5127fedf0291927c9345caf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f646572666c65782f6c61726176656c2d7469636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coderflex/laravel-ticket)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8a40093dd9f5ba52de78555a58173dd65f1462757c4ebb88e5ed093db8a258fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636f646572666c6578782f6c61726176656c2d7469636b65742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/coderflexx/laravel-ticket/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ee04603031803e27c034e50015b541549a539a182f87a8e8ef1edf03196dc414/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636f646572666c6578782f6c61726176656c2d7469636b65742f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/coderflexx/laravel-ticket/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/631b79529ae600a2a0bd8b7428d21f35712f1112708aad5ddc7fff1e4aa4e004/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f646572666c65782f6c61726176656c2d7469636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coderflex/laravel-ticket)

- [Introduction](#introduction)
- [Installation](#installation)
- [Configuration](#configuration)
- [Preparing your model](#preparing-your-model)
- [Usage](#usage)
    - [Ticket Table Structure](#ticket-table-structure)
    - [Message Table Structure](#message-table-structure)
    - [Label Table Structure](#label-table-structure)
    - [Category Table Structure](#category-table-structure)
- [API Methods](#api-methods)
    - [Ticket API Methods](#ticket-api-methods)
    - [Ticket Relationship API Methods](#ticket-relationship-api-methods)
    - [Ticket Scopes](#ticket-scopes)
    - [Category &amp; Label Scopes](#category--label-scopes)
- [Handling File Upload](#handling-file-upload)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

**Laravel Ticket** package, is a Backend API to handle your ticket system, with an easy way. This is apapted fork for php 7.4.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require shamazingg/laravel-ticket
```

Configuration
-------------

[](#configuration)

You can publish the config file with:

```
php artisan vendor:publish --tag="ticket-config"
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="ticket-migrations"
```

Before Running the migration, you may publish the config file, and make sure the current tables does not make a conflict with your existing application, and once you are happy with the migration table, you can run

```
php artisan migrate
```

Preparing your model
--------------------

[](#preparing-your-model)

Add `HasTickets` trait into your `User` model, along with `CanUseTickets` interface

```
...
use Coderflex\LaravelTicket\Concerns\HasTickets;
use Coderflex\LaravelTicket\Contracts\CanUseTickets;
...
class User extends Model implements CanUseTickets
{
    ...
    use HasTickets;
    ...
}
```

Usage
-----

[](#usage)

The Basic Usage of this package, is to create a `ticket`, then associate the `labels` and the `categories` to it.

You can associate as many as `categories`/`labels` into a single ticket.

Here is an example

```
use Coderflex\LaravelTicket\Models\Ticket;
use Coderflex\LaravelTicket\Models\Category;
use Coderflex\LaravelTicket\Models\Label;

...
public function store(Request $request)
{
    /** @var User */
    $user = Auth::user();

    $ticket = $user->tickets()
                    ->create($request->validated());

    $categories = Category::first();
    $labels = Label::first();

    $ticket->attachCategories($categories);
    $ticket->attachLabels($labels);

    // or you can create the categories & the tickets directly by:
    // $ticket->categories()->create(...);
    // $ticket->labels()->create(...);

    return redirect(route('tickets.show', $ticket->uuid))
            ->with('success', __('Your Ticket Was created successfully.'));
}

public function createLabel()
{
    // If you create a label seperated from the ticket and wants to
    // associate it to a ticket, you may do the following.
    $label = Label::create(...);

    $label->tickets()->attach($ticket);

    // or maybe
    $label->tickets()->detach($ticket);
}

public function createCategory()
{
    // If you create a category/categories seperated from the ticket and wants to
    // associate it to a ticket, you may do the following.
    $category = Category::create(...);

    $category->tickets()->attach($ticket);

    // or maybe
    $category->tickets()->detach($ticket);
}
...
```

### Ticket Table Structure

[](#ticket-table-structure)

Column NameTypeDefaultID`integer``NOT NULL`UUID`string``NULL`user\_id`integer``NOT NULL`title`string``NOT NULL`message`string``NULL`priority`string``low`status`string``open`is\_resolved`boolean``false`is\_locked`boolean``false`created\_at`timestamp``NULL`updated\_at`timestamp``NULL`### Message Table Structure

[](#message-table-structure)

Column NameTypeDefaultID`integer``NOT NULL`user\_id`integer``NOT NULL`ticket\_id`integer``NOT NULL`message`string``NULL`created\_at`timestamp``NULL`updated\_at`timestamp``NULL`### Label Table Structure

[](#label-table-structure)

Column NameTypeDefaultID`integer``NOT NULL`name`string``NULL`slug`string``NULL`is\_visible`boolean``false`created\_at`timestamp``NULL`updated\_at`timestamp``NULL`### Category Table Structure

[](#category-table-structure)

Column NameTypeDefaultID`integer``NOT NULL`name`string``NULL`slug`string``NULL`is\_visible`boolean``false`created\_at`timestamp``NULL`updated\_at`timestamp``NULL`API Methods
-----------

[](#api-methods)

### Ticket API Methods

[](#ticket-api-methods)

The `ticket` model came with handy methods to use, to make your building process easy and fast, and here is the list of the available **API**:

MethodArgumentsDescriptionExampleChainable`archive``void`archive the ticket`$ticket->archive()`✓`close``void`close the ticket`$ticket->close()`✓`reopen``void`reopen a closed ticket`$ticket->reopen()`✓`markAsResolved``void`mark the ticket as resolved`$ticket->markAsResolved()`✓`markAsLocked``void`mark the ticket as locked`$ticket->markAsLocked()`✓`markAsUnlocked``void`mark the ticket as unlocked`$ticket->markAsUnlocked()`✓`markAsArchived``void`mark the ticket as archived`$ticket->markAsArchived()`✓`closeAsResolved``void`close the ticket and marked it as resolved`$ticket->closeAsResolved()`✓`closeAsUnresolved``void`close the ticket and marked it as unresolved`$ticket->closeAsUnresolved()`✓`reopenAsUnresolved``void`reopen the ticket and marked it as unresolved`$ticket->reopenAsUnresolved()`✓`isArchived``void`check if the ticket archived`$ticket->isArchived()`✗`isOpen``void`check if the ticket open`$ticket->isOpen()`✗`isClosed``void`check if the ticket closed`$ticket->isClosed()`✗`isResolved``void`check if the ticket has a resolved status`$ticket->isResolved()`✗`isUnresolved``void`check if the ticket has an unresolved status`$ticket->isUnresolved()`✗`isLocked``void`check if the ticket is locked`$ticket->isLocked()`✗`isUnlocked``void`check if the ticket is unlocked`$ticket->isUnlocked()`✗The **Chainable** column, is showing the state for the method, that if it can be chained or not, something like

```
    $ticket->archive()
            ->close()
            ->markAsResolved();
```

### Ticket Relationship API Methods

[](#ticket-relationship-api-methods)

The `ticket` model has also a list of methods for interacting with another related models

MethodArgumentsDescriptionExample`attachLabels``mixed` ID, `array` attributes, `bool` touchassociate labels into an existing ticket`$ticket->attachLabels([1,2,3,4])``syncLabels``Model/array` IDs, `bool` detouchingassociate labels into an existing ticket`$ticket->syncLabels([1,2,3,4])``attachCategories``mixed` ID, `array` attributes, `bool` touchassociate categories into an existing ticket`$ticket->attachCategories([1,2,3,4])``syncCategories``Model/array` IDs, `bool` detouchingassociate categories into an existing ticket`$ticket->syncCategories([1,2,3,4])``message``string` messageadd new message on an existing ticket`$ticket->message('A message in a ticket')``messageAsUser``Model/null` user, `string` messageadd new message on an existing ticket as a different user`$ticket->messageAsUser($user, 'A message in a ticket')`> The `attachCategories` and `syncCategories` methods, is an alternative for `attach` and `sync` laravel methods, and if you want to learn more, please take a look at this [link](https://laravel.com/docs/9.x/eloquent-relationships#attaching-detaching)

The `commentAsUser` accepts a user as a first argument, if it's null, the **authenticated** user will be user as default.

### Ticket Scopes

[](#ticket-scopes)

The `ticket` model has also a list of scopes to begin filter with.

MethodArgumentsDescriptionExample`closed``void`get the closed tickets`Ticket::closed()->get()``opened``void`get the opened tickets`Ticket::opened()->get()``resolved``void`get the resolved tickets`Ticket::resolved()->get()``locked``void`get the locked tickets`Ticket::locked()->get()``unlocked``void`get the unlocked tickets`Ticket::unlocked()->get()``withLowPriority``void`get the low priority tickets`Ticket::withLowPriority()->get()``withNormalPriority``void`get the normal priority tickets`Ticket::withNormalPriority()->get()``withHighPriority``void`get the high priority tickets`Ticket::withHighPriority()->get()``withPriority``string` $priorityget the withPriority tickets`Ticket::withPriority('critical')->get()`### Category &amp; Label Scopes

[](#category--label-scopes)

MethodArgumentsDescriptionExample`visible``void`get the visible model records`Label::visible()->get()``hidden``void`get the hidden model records`Category::visible()->get()`Handling File Upload
--------------------

[](#handling-file-upload)

This package doesn't come with file upload feature (yet) Instead you can use [laravel-medialibrary](https://github.com/spatie/laravel-medialibrary) by **Spatie**, to handle file functionality.

The steps are pretty straight forward, all what you need to do is the following.

Extends the `Ticket` model, by creating a new model file in your application by

```
php artisan make:model Ticket

```

Then extend the base `Ticket Model`, then use `InteractWithMedia` trait by spatie package, and the interface `HasMedia`:

```
namespace App\Models\Ticket;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Ticket extends \Coderflex\LaravelTicket\Models\Ticket implements HasMedia
{
    use InteractsWithMedia;
}
```

The rest of the implementation, head to [the docs](https://spatie.be/docs/laravel-medialibrary/v10/introduction) of spatie package to know more.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [ousid](https://github.com/ousid)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 94.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3061ee6ea61fd69fff0198075ef32ea673000b7024082f9f961b970ce202888e?d=identicon)[ShamazinGG](/maintainers/ShamazinGG)

---

Top Contributors

[![ousid](https://avatars.githubusercontent.com/u/21012933?v=4)](https://github.com/ousid "ousid (50 commits)")[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/shamazingg-laravel-ticket/health.svg)

```
[![Health](https://phpackages.com/badges/shamazingg-laravel-ticket/health.svg)](https://phpackages.com/packages/shamazingg-laravel-ticket)
```

###  Alternatives

[justcoded/wordpress-theme-boilerplate

WordPress theme boilerplate with better code structure and OOP support.

563.9k1](/packages/justcoded-wordpress-theme-boilerplate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
