{"id":20428216,"url":"https://github.com/coderflexx/laravel-ticket","last_synced_at":"2025-05-16T13:04:31.778Z","repository":{"id":60138536,"uuid":"540619633","full_name":"coderflexx/laravel-ticket","owner":"coderflexx","description":"Laravel Ticket System, to help you manage your tickets easily.","archived":false,"fork":false,"pushed_at":"2025-03-19T13:39:37.000Z","size":192,"stargazers_count":396,"open_issues_count":1,"forks_count":79,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-11T14:05:01.653Z","etag":null,"topics":["eloquent","laravel","ticketing-system"],"latest_commit_sha":null,"homepage":"https://coderflex.com/open-source/docs/laravel-ticket/introduction","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderflexx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"ko_fi":"ousid","custom":["https://www.buymeacoffee.com/ousid"]}},"created_at":"2022-09-23T21:15:20.000Z","updated_at":"2025-04-30T14:57:07.000Z","dependencies_parsed_at":"2024-01-15T03:18:50.897Z","dependency_job_id":"df5e03c2-f652-4f5f-a032-a9da6b4bd1e9","html_url":"https://github.com/coderflexx/laravel-ticket","commit_stats":{"total_commits":68,"total_committers":8,"mean_commits":8.5,"dds":0.3529411764705882,"last_synced_commit":"c8caa2f525832f099b441028afbde753dfe4b0c3"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderflexx%2Flaravel-ticket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderflexx%2Flaravel-ticket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderflexx%2Flaravel-ticket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderflexx%2Flaravel-ticket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderflexx","download_url":"https://codeload.github.com/coderflexx/laravel-ticket/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535826,"owners_count":22087398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","laravel","ticketing-system"],"created_at":"2024-11-15T07:24:40.256Z","updated_at":"2025-05-16T13:04:31.712Z","avatar_url":"https://github.com/coderflexx.png","language":"PHP","funding_links":["https://ko-fi.com/ousid","https://www.buymeacoffee.com/ousid"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"art/logo.png\" alt=\"Laravisit Logo\" width=\"300\"\u003e\n    \u003cbr\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/coderflex/laravel-ticket.svg?style=flat-square)](https://packagist.org/packages/coderflex/laravel-ticket)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-ticket/run-tests.yml?branch=main\u0026label=test)](https://github.com/coderflexx/laravel-ticket/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/coderflexx/laravel-ticket/phpstan.yml?branch=main\u0026label=code%20style)](https://github.com/coderflexx/laravel-ticket/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/coderflex/laravel-ticket.svg?style=flat-square)](https://packagist.org/packages/coderflex/laravel-ticket)\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Preparing your model](#preparing-your-model)\n- [Usage](#usage)\n  - [Ticket Table Structure](#ticket-table-structure)\n  - [Message Table Structure](#message-table-structure)\n  - [Label Table Structure](#label-table-structure)\n  - [Category Table Structure](#category-table-structure)\n- [API Methods](#api-methods)\n  - [Ticket API Methods](#ticket-api-methods)\n  - [Ticket Relationship API Methods](#ticket-relationship-api-methods)\n  - [Ticket Scopes](#ticket-scopes)\n  - [Category \\\u0026 Label Scopes](#category--label-scopes)\n- [Handling File Upload](#handling-file-upload)\n- [Testing](#testing)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Security Vulnerabilities](#security-vulnerabilities)\n- [Credits](#credits)\n- [License](#license)\n\n## Introduction\n__Laravel Ticket__ package, is a Backend API to handle your ticket system, with an easy way.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require coderflex/laravel-ticket\n```\n\n## Configuration\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"ticket-config\"\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"ticket-migrations\"\n```\nBefore 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\n\n```bash\nphp artisan migrate\n```\n\n## Preparing your model\n\nAdd `HasTickets` trait into your `User` model, along with `CanUseTickets` interface\n\n```php\n...\nuse Coderflex\\LaravelTicket\\Concerns\\HasTickets;\nuse Coderflex\\LaravelTicket\\Contracts\\CanUseTickets;\n...\nclass User extends Model implements CanUseTickets\n{\n    ...\n    use HasTickets;\n    ...\n}\n```\n\n## Usage\n\nThe Basic Usage of this package, is to create a `ticket`, then associate the `labels` and the `categories` to it.\n\nYou can associate as many as `categories`/`labels` into a single ticket.\n\nHere is an example\n\n```php\nuse Coderflex\\LaravelTicket\\Models\\Ticket;\nuse Coderflex\\LaravelTicket\\Models\\Category;\nuse Coderflex\\LaravelTicket\\Models\\Label;\n\n...\npublic function store(Request $request)\n{\n    /** @var User */\n    $user = Auth::user();\n\n    $ticket = $user-\u003etickets()\n                    -\u003ecreate($request-\u003evalidated());\n\n    $category = Category::first();\n    $label = Label::first();\n\n    $ticket-\u003eattachCategories($category);\n    $ticket-\u003eattachLabels($label);\n    \n    // or you can create the categories \u0026 the tickets directly by:\n    // $ticket-\u003ecategories()-\u003ecreate(...);\n    // $ticket-\u003elabels()-\u003ecreate(...);\n\n    return redirect(route('tickets.show', $ticket-\u003euuid))\n            -\u003ewith('success', __('Your Ticket Was created successfully.'));\n}\n\npublic function createLabel()\n{\n    // If you create a label seperated from the ticket and wants to\n    // associate it to a ticket, you may do the following.\n    $label = Label::create(...);\n\n    $label-\u003etickets()-\u003eattach($ticket);\n\n    // or maybe \n    $label-\u003etickets()-\u003edetach($ticket);\n}\n\npublic function createCategory()\n{\n    // If you create a category/categories seperated from the ticket and wants to\n    // associate it to a ticket, you may do the following.\n    $category = Category::create(...);\n\n    $category-\u003etickets()-\u003eattach($ticket);\n\n    // or maybe \n    $category-\u003etickets()-\u003edetach($ticket);\n}\n...\n```\n\n### Ticket Table Structure\n\n| Column Name  | Type  |  Default  |\n|---|---|---|\n|  ID |`integer` | `NOT NULL`  |\n|  UUID |`string` | `NULL`  |\n|  user_id |`integer` | `NOT NULL`  |\n|  title |`string` | `NOT NULL`  |\n|  message |`string` | `NULL`  |\n|  priority |`string` | `low`  |\n|  status |`string` | `open`  |\n|  is_resolved |`boolean` | `false`  |\n|  is_locked |`boolean` | `false`  |\n| assigned_to | `integer` | `NULL` |\n|  created_at |`timestamp` | `NULL`  |\n|  updated_at |`timestamp` | `NULL`  |\n\n### Message Table Structure\n\n| Column Name  | Type  |  Default  |\n|---|---|---|\n|  ID |`integer` | `NOT NULL`  |\n|  user_id |`integer` | `NOT NULL`  |\n|  ticket_id |`integer` | `NOT NULL`  |\n|  message |`string` | `NULL`  |\n|  created_at |`timestamp` | `NULL`  |\n|  updated_at |`timestamp` | `NULL`  |\n\n### Label Table Structure\n\n| Column Name  | Type  |  Default  |\n|---|---|---|\n|  ID |`integer` | `NOT NULL`  |\n|  name |`string` | `NULL`  |\n|  slug |`string` | `NULL`  |\n|  is_visible |`boolean` | `false`  |\n|  created_at |`timestamp` | `NULL`  |\n|  updated_at |`timestamp` | `NULL`  |\n\n### Category Table Structure\n\n| Column Name  | Type  |  Default  |\n|---|---|---|\n|  ID |`integer` | `NOT NULL`  |\n|  name |`string` | `NULL`  |\n|  slug |`string` | `NULL`  |\n|  is_visible |`boolean` | `false`  |\n|  created_at |`timestamp` | `NULL`  |\n|  updated_at |`timestamp` | `NULL`  |\n\n## API Methods\n\n### Ticket API Methods\nThe `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__:\n\n| Method               | Arguments  | Description                                   | Example                                             | Chainable |\n|----------------------|---|-----------------------------------------------|-----------------------------------------------------|---|\n| `archive`            |`void` | archive the ticket                            | `$ticket-\u003earchive()`                                | ✓\n| `close`              |`void` | close the ticket                              | `$ticket-\u003eclose()`                                  | ✓\n| `reopen`             |`void` | reopen a closed ticket                        | `$ticket-\u003ereopen()`                                 | ✓\n| `markAsResolved`     |`void` | mark the ticket as resolved                   | `$ticket-\u003emarkAsResolved()`                         | ✓\n| `markAsLocked`       |`void` | mark the ticket as locked                     | `$ticket-\u003emarkAsLocked()`                           | ✓\n| `markAsUnlocked`     |`void` | mark the ticket as unlocked                   | `$ticket-\u003emarkAsUnlocked()`                         | ✓\n| `markAsArchived`     |`void` | mark the ticket as archived                   | `$ticket-\u003emarkAsArchived()`                         | ✓\n| `closeAsResolved`    |`void` | close the ticket and marked it as resolved    | `$ticket-\u003ecloseAsResolved()`                        | ✓\n| `closeAsUnresolved`  |`void` | close the ticket and marked it as unresolved  | `$ticket-\u003ecloseAsUnresolved()`                      | ✓\n| `reopenAsUnresolved` |`void` | reopen the ticket and marked it as unresolved | `$ticket-\u003ereopenAsUnresolved()`                     | ✓\n| `isArchived`         |`void` | check if the ticket archived                  | `$ticket-\u003eisArchived()`                             | ✗\n| `isOpen`             |`void` | check if the ticket open                      | `$ticket-\u003eisOpen()`                                 | ✗\n| `isClosed`           |`void` | check if the ticket closed                    | `$ticket-\u003eisClosed()`                               | ✗\n| `isResolved`         |`void` | check if the ticket has a resolved status     | `$ticket-\u003eisResolved()`                             | ✗\n| `isUnresolved`       |`void` | check if the ticket has an unresolved status  | `$ticket-\u003eisUnresolved()`                           | ✗\n| `isLocked`           |`void` | check if the ticket is locked                 | `$ticket-\u003eisLocked()`                               | ✗\n| `isUnlocked`         |`void` | check if the ticket is unlocked               | `$ticket-\u003eisUnlocked()`                             | ✗\n| `assignTo`           |`void` | assign ticket to a user                       | `$ticket-\u003eassignTo($user)` or `$ticket-\u003eassignTo(2)` | ✓\n| `makePriorityAsLow`  |`void` | make ticket priority as low                   | `$ticket-\u003emakePriorityAsLow()`                      | ✓\n| `makePriorityAsNormal`|`void`| make ticket priority as normal                | `$ticket-\u003emakePriorityAsNormal()`                   | ✓\n| `makePriorityAsHigh` |`void` | make ticket priority as high                  | `$ticket-\u003emakePriorityAsHigh()`                     | ✓\n\nThe __Chainable__ column, is showing the state for the method, that if it can be chained or not, something like\n```php\n    $ticket-\u003earchive()\n            -\u003eclose()\n            -\u003emarkAsResolved();\n```\n### Ticket Relationship API Methods\nThe `ticket` model has also a list of methods for interacting with another related models\n\n| Method  | Arguments  |  Description  |  Example  |\n|---|---|---|---|\n|  `attachLabels` |`mixed` ID, `array` attributes, `bool` touch | associate labels into an existing ticket  | `$ticket-\u003eattachLabels([1,2,3,4])` |\n|  `syncLabels` |`Model/array` IDs, `bool` detouching | associate labels into an existing ticket  | `$ticket-\u003esyncLabels([1,2,3,4])` |\n|  `attachCategories` |`mixed` ID, `array` attributes, `bool` touch | associate categories into an existing ticket  | `$ticket-\u003eattachCategories([1,2,3,4])` |\n|  `syncCategories` |`Model/array` IDs, `bool` detouching | associate categories into an existing ticket  | `$ticket-\u003esyncCategories([1,2,3,4])` |\n|  `message` |`string` message | add new message on an existing ticket  | `$ticket-\u003emessage('A message in a ticket')` |\n|  `messageAsUser` |`Model/null` user, `string` message | add new message on an existing ticket as a different user  | `$ticket-\u003emessageAsUser($user, 'A message in a ticket')` |\n\n\u003e 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)\n\nThe `commentAsUser` accepts a user as a first argument, if it's null, the __authenticated__ user will be user as default.\n\n### Ticket Scopes\nThe `ticket` model has also a list of scopes to begin filter with.\n\n| Method  | Arguments  |  Description  |  Example  |\n|---|---|---|---|\n|  `closed` |`void` | get the closed tickets  | `Ticket::closed()-\u003eget()` |\n|  `opened` |`void` | get the opened tickets  | `Ticket::opened()-\u003eget()` |\n|  `archived` |`void` | get the archived tickets  | `Ticket::archived()-\u003eget()` |\n|  `unArchived` |`void` | get the unArchived tickets  | `Ticket::unArchived()-\u003eget()` |\n|  `resolved` |`void` | get the resolved tickets  | `Ticket::resolved()-\u003eget()` |\n|  `locked` |`void` | get the locked tickets  | `Ticket::locked()-\u003eget()` |\n|  `unlocked` |`void` | get the unlocked tickets  | `Ticket::unlocked()-\u003eget()` |\n|  `withLowPriority` |`void` | get the low priority tickets  | `Ticket::withLowPriority()-\u003eget()` |\n|  `withNormalPriority` |`void` | get the normal priority tickets  | `Ticket::withNormalPriority()-\u003eget()` |\n|  `withHighPriority` |`void` | get the high priority tickets  | `Ticket::withHighPriority()-\u003eget()` |\n|  `withPriority` |`string` $priority | get the withPriority tickets  | `Ticket::withPriority('critical')-\u003eget()` |\n\n### Category \u0026 Label Scopes\n| Method  | Arguments  |  Description  |  Example  |\n|---|---|---|---|\n|  `visible` |`void` | get the visible model records  | `Label::visible()-\u003eget()` |\n|  `hidden` |`void` | get the hidden model records  | `Category::visible()-\u003eget()` |\n\n## Handling File Upload\nThis package doesn't come with file upload feature (yet) Instead you can use [laravel-medialibrary](https://github.com/spatie/laravel-medialibrary) by __Spatie__,\nto handle file functionality.\n\nThe steps are pretty straight forward, all what you need to do is the following.\n\nExtends the `Ticket` model, by creating a new model file in your application by\n```\nphp artisan make:model Ticket\n```\n\nThen extend the base `Ticket Model`, then use `InteractWithMedia` trait by spatie package, and the interface `HasMedia`:\n\n```php\nnamespace App\\Models\\Ticket;\nuse Spatie\\MediaLibrary\\HasMedia;\nuse Spatie\\MediaLibrary\\InteractsWithMedia;\n\nclass Ticket extends \\Coderflex\\LaravelTicket\\Models\\Ticket implements HasMedia\n{\n    use InteractsWithMedia;\n}\n```\n\nThe rest of the implementation, head to [the docs](https://spatie.be/docs/laravel-medialibrary/v10/introduction) of spatie package to know more.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [ousid](https://github.com/ousid)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderflexx%2Flaravel-ticket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderflexx%2Flaravel-ticket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderflexx%2Flaravel-ticket/lists"}