Skip to content

Commit c623e5e

Browse files
committed
Fixed some bugs, updated readme, removed controller and use instead TicketControllable as trait
1 parent ac2f13c commit c623e5e

File tree

5 files changed

+87
-32
lines changed

5 files changed

+87
-32
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,33 @@ class User
6060

6161
The ticket routes can be implemented via the macro
6262
```php
63-
Route::tickets();
63+
64+
class TicketController extends Controller {
65+
66+
use \RexlManu\LaravelTickets\Controllers\TicketControllable;
67+
68+
}
69+
70+
Route::tickets( TicketController::class );
71+
```
72+
73+
For ticket referneces
74+
```php
75+
76+
class ExampleModel extends Model implements \RexlManu\LaravelTickets\Interfaces\TicketReference {
77+
78+
use \RexlManu\LaravelTickets\Traits\HasTicketReference;
79+
80+
// Check if user has access to this model
81+
function hasReferenceAccess() : bool {
82+
return request()->user()->user_id == $this->user_id;
83+
}
84+
85+
}
86+
6487
```
88+
Add this model to the list of reference models now
89+
and Then you should see this model as reference
6590

6691
Config: All points of the configuration are documented.
6792

resources/lang/de.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"You have reached the limit of open tickets": "Sie haben die Grenze der offenen Tickets erreicht",
3+
"The ticket was successfully created": "Das Ticket wurde erfolgreich erstellt",
4+
"You cannot reply to a closed ticket": "Sie können nicht auf ein geschlossenes Ticket antworten.",
5+
"Your answer was sent successfully": "Ihre Antwort wurde erfolgreich gesendet",
6+
"The ticket is already closed": "Das Ticket ist bereits geschlossen",
7+
"The ticket was successfully closed": "Das Ticket wurde erfolgreich abgeschlossen",
8+
"High": "Hoch",
9+
"Mid": "Mittel",
10+
"Low": "Niedrig",
11+
"Closed": "Geschlossen",
12+
"Open": "Offen",
13+
"Answer": "Beantwortet",
14+
"Reference": "Bezug",
15+
"Subject": "Betreff",
16+
"Priority": "Priorität",
17+
"State": "Status",
18+
"Choose files": "Wähle Dateien aus",
19+
"Ticket answer": "Ticket beantworten",
20+
"Send": "Absenden",
21+
"Ticket overview": "Ticket Übersicht",
22+
"Message": "Nachricht",
23+
"No reference": "Kein Bezug",
24+
"Create": "Erstellen",
25+
"Open ticket": "Ticket eröffnen",
26+
"Last Update": "Letzte Aktualisierung",
27+
"Created at": "Erstellt am",
28+
"Action": "Aktion",
29+
"Show": "Anzeigen",
30+
"Close ticket": "Ticket schließen",
31+
"Not updated": "Nicht aktualisiert",
32+
"Deleted user": "Benutzer gelöscht",
33+
"The reference is not valid": "Der Bezug ist ungültig",
34+
"Category": "Kategorie"
35+
}
36+

resources/views/tickets/show.blade.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
</div>
1313
<div class="card-body">
1414
<form method="post" action="{{ route('laravel-tickets.tickets.message', compact('ticket')) }}"
15-
@if (config('laravel-tickets.files'))
16-
enctype="multipart/form-data"
17-
@endif>
15+
@if (config('laravel-tickets.files')) enctype="multipart/form-data" @endif>
1816
@csrf
1917
<textarea class="form-control @error('message') is-invalid @enderror"
2018
placeholder="@lang('Message')" name="message">{{ old('message') }}</textarea>
@@ -39,9 +37,7 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
3937
@endif
4038

4139
@foreach ($messages as $message)
42-
<div class="card @if (! $loop->first)
43-
mt-2
44-
@endif">
40+
<div class="card @if (! $loop->first) mt-2 @endif">
4541
<div class="card-header">
4642
<div class="row">
4743
<div class="col">
@@ -57,8 +53,8 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
5753
{!! nl2br(e($message->message)) !!}
5854
</div>
5955
</div>
60-
<div class="card-body border-top p-1">
61-
@if ($message->uploads()->count() > 0)
56+
@if ($message->uploads()->count() > 0)
57+
<div class="card-body border-top p-1">
6258
<div class="row mt-1 mb-2 pr-2 pl-2">
6359
@foreach ($message->uploads()->get() as $ticketUpload)
6460
<div class="col">
@@ -68,8 +64,8 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
6864
</div>
6965
@endforeach
7066
</div>
71-
@endif
72-
</div>
67+
</div>
68+
@endif
7369

7470
</div>
7571
@endforeach

src/Controllers/TicketController.php renamed to src/Controllers/TicketControllable.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
namespace RexlManu\LaravelTickets\Controllers;
55

66

7-
use Illuminate\Database\Eloquent\Relations\Relation;
87
use Illuminate\Http\JsonResponse;
98
use Illuminate\Http\RedirectResponse;
109
use Illuminate\Http\Request;
11-
use Illuminate\Routing\Controller;
1210
use Illuminate\Validation\Rule;
1311
use Illuminate\View\View;
1412
use RexlManu\LaravelTickets\Events\TicketCloseEvent;
@@ -30,11 +28,11 @@
3028
*
3129
* @package RexlManu\LaravelTickets\Controllers
3230
*/
33-
class TicketController extends Controller
31+
trait TicketControllable
3432
{
3533

3634
/**
37-
* @link TicketController constructor
35+
* @link TicketControllable constructor
3836
*/
3937
public function __construct()
4038
{

src/LaravelTicketsServiceProvider.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Support\ServiceProvider;
66
use RexlManu\LaravelTickets\Commands\AutoCloseCommand;
7-
use RexlManu\LaravelTickets\Controllers\TicketController;
7+
use RexlManu\LaravelTickets\Controllers\TicketControllable;
88
use Illuminate\Routing\Router;
99
use Illuminate\Support\Facades\Route;
1010
use RexlManu\LaravelTickets\Models\Ticket;
@@ -24,7 +24,7 @@ public function boot()
2424
/*
2525
* Optional methods to load your package assets
2626
*/
27-
// $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'laravel-tickets');
27+
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'laravel-tickets');
2828
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'laravel-tickets');
2929
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
3030
$this->routes();
@@ -50,9 +50,9 @@ public function boot()
5050
], 'assets');*/
5151

5252
// Publishing the translation files.
53-
// $this->publishes([
54-
// __DIR__ . '/../resources/lang' => resource_path('lang/vendor/laravel-tickets'),
55-
// ], 'lang');
53+
$this->publishes([
54+
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/laravel-tickets'),
55+
], 'lang');
5656

5757
// Registering package commands.
5858
$this->commands([ AutoCloseCommand::class ]);
@@ -77,18 +77,18 @@ public function routes()
7777
{
7878
// Macro routing
7979
foreach ([ 'ticketSystem', 'tickets' ] as $routeMacroName) {
80-
Router::macro($routeMacroName, function () {
81-
Route::middleware(config('laravel-tickets.guard'))->name('laravel-tickets.')->group(function () {
82-
Route::prefix('/tickets')->group(function () {
83-
Route::get('/', [ TicketController::class, 'index' ])->name('tickets.index');
84-
Route::post('/', [ TicketController::class, 'store' ])->name('tickets.store');
85-
Route::get('/create', [ TicketController::class, 'create' ])->name('tickets.create');
86-
Route::prefix('{ticket}')->group(function () {
87-
Route::get('/', [ TicketController::class, 'show' ])->name('tickets.show');
88-
Route::post('/', [ TicketController::class, 'close' ])->name('tickets.close');
89-
Route::post('/message', [ TicketController::class, 'message' ])->name('tickets.message');
90-
Route::prefix('{ticketUpload}')->group(function () {
91-
Route::get('/download', [ TicketController::class, 'download' ])->name('tickets.download');
80+
Router::macro($routeMacroName, function ($controller) {
81+
Route::middleware(config('laravel-tickets.guard'))->name('laravel-tickets.')->group(function () use ($controller) {
82+
Route::prefix('/tickets')->group(function () use ($controller) {
83+
Route::get('/', [ $controller, 'index' ])->name('tickets.index');
84+
Route::post('/', [ $controller, 'store' ])->name('tickets.store');
85+
Route::get('/create', [ $controller, 'create' ])->name('tickets.create');
86+
Route::prefix('{ticket}')->group(function () use ($controller) {
87+
Route::get('/', [ $controller, 'show' ])->name('tickets.show');
88+
Route::post('/', [ $controller, 'close' ])->name('tickets.close');
89+
Route::post('/message', [ $controller, 'message' ])->name('tickets.message');
90+
Route::prefix('{ticketUpload}')->group(function () use ($controller) {
91+
Route::get('/download', [ $controller, 'download' ])->name('tickets.download');
9292
});
9393
});
9494
});

0 commit comments

Comments
 (0)