Skip to content

Commit

Permalink
Fixed some bugs, updated readme, removed controller and use instead T…
Browse files Browse the repository at this point in the history
…icketControllable as trait
  • Loading branch information
rexlManu committed Nov 19, 2020
1 parent ac2f13c commit c623e5e
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 32 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,33 @@ class User

The ticket routes can be implemented via the macro
```php
Route::tickets();

class TicketController extends Controller {

use \RexlManu\LaravelTickets\Controllers\TicketControllable;

}

Route::tickets( TicketController::class );
```

For ticket referneces
```php

class ExampleModel extends Model implements \RexlManu\LaravelTickets\Interfaces\TicketReference {

use \RexlManu\LaravelTickets\Traits\HasTicketReference;

// Check if user has access to this model
function hasReferenceAccess() : bool {
return request()->user()->user_id == $this->user_id;
}

}

```
Add this model to the list of reference models now
and Then you should see this model as reference

Config: All points of the configuration are documented.

Expand Down
36 changes: 36 additions & 0 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"You have reached the limit of open tickets": "Sie haben die Grenze der offenen Tickets erreicht",
"The ticket was successfully created": "Das Ticket wurde erfolgreich erstellt",
"You cannot reply to a closed ticket": "Sie können nicht auf ein geschlossenes Ticket antworten.",
"Your answer was sent successfully": "Ihre Antwort wurde erfolgreich gesendet",
"The ticket is already closed": "Das Ticket ist bereits geschlossen",
"The ticket was successfully closed": "Das Ticket wurde erfolgreich abgeschlossen",
"High": "Hoch",
"Mid": "Mittel",
"Low": "Niedrig",
"Closed": "Geschlossen",
"Open": "Offen",
"Answer": "Beantwortet",
"Reference": "Bezug",
"Subject": "Betreff",
"Priority": "Priorität",
"State": "Status",
"Choose files": "Wähle Dateien aus",
"Ticket answer": "Ticket beantworten",
"Send": "Absenden",
"Ticket overview": "Ticket Übersicht",
"Message": "Nachricht",
"No reference": "Kein Bezug",
"Create": "Erstellen",
"Open ticket": "Ticket eröffnen",
"Last Update": "Letzte Aktualisierung",
"Created at": "Erstellt am",
"Action": "Aktion",
"Show": "Anzeigen",
"Close ticket": "Ticket schließen",
"Not updated": "Nicht aktualisiert",
"Deleted user": "Benutzer gelöscht",
"The reference is not valid": "Der Bezug ist ungültig",
"Category": "Kategorie"
}

16 changes: 6 additions & 10 deletions resources/views/tickets/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
</div>
<div class="card-body">
<form method="post" action="{{ route('laravel-tickets.tickets.message', compact('ticket')) }}"
@if (config('laravel-tickets.files'))
enctype="multipart/form-data"
@endif>
@if (config('laravel-tickets.files')) enctype="multipart/form-data" @endif>
@csrf
<textarea class="form-control @error('message') is-invalid @enderror"
placeholder="@lang('Message')" name="message">{{ old('message') }}</textarea>
Expand All @@ -39,9 +37,7 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
@endif

@foreach ($messages as $message)
<div class="card @if (! $loop->first)
mt-2
@endif">
<div class="card @if (! $loop->first) mt-2 @endif">
<div class="card-header">
<div class="row">
<div class="col">
Expand All @@ -57,8 +53,8 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
{!! nl2br(e($message->message)) !!}
</div>
</div>
<div class="card-body border-top p-1">
@if ($message->uploads()->count() > 0)
@if ($message->uploads()->count() > 0)
<div class="card-body border-top p-1">
<div class="row mt-1 mb-2 pr-2 pl-2">
@foreach ($message->uploads()->get() as $ticketUpload)
<div class="col">
Expand All @@ -68,8 +64,8 @@ class="custom-file-input @error('files') is-invalid @enderror" id="files">
</div>
@endforeach
</div>
@endif
</div>
</div>
@endif

</div>
@endforeach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
namespace RexlManu\LaravelTickets\Controllers;


use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Validation\Rule;
use Illuminate\View\View;
use RexlManu\LaravelTickets\Events\TicketCloseEvent;
Expand All @@ -30,11 +28,11 @@
*
* @package RexlManu\LaravelTickets\Controllers
*/
class TicketController extends Controller
trait TicketControllable
{

/**
* @link TicketController constructor
* @link TicketControllable constructor
*/
public function __construct()
{
Expand Down
34 changes: 17 additions & 17 deletions src/LaravelTicketsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\ServiceProvider;
use RexlManu\LaravelTickets\Commands\AutoCloseCommand;
use RexlManu\LaravelTickets\Controllers\TicketController;
use RexlManu\LaravelTickets\Controllers\TicketControllable;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use RexlManu\LaravelTickets\Models\Ticket;
Expand All @@ -24,7 +24,7 @@ public function boot()
/*
* Optional methods to load your package assets
*/
// $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'laravel-tickets');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'laravel-tickets');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'laravel-tickets');
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->routes();
Expand All @@ -50,9 +50,9 @@ public function boot()
], 'assets');*/

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

// Registering package commands.
$this->commands([ AutoCloseCommand::class ]);
Expand All @@ -77,18 +77,18 @@ public function routes()
{
// Macro routing
foreach ([ 'ticketSystem', 'tickets' ] as $routeMacroName) {
Router::macro($routeMacroName, function () {
Route::middleware(config('laravel-tickets.guard'))->name('laravel-tickets.')->group(function () {
Route::prefix('/tickets')->group(function () {
Route::get('/', [ TicketController::class, 'index' ])->name('tickets.index');
Route::post('/', [ TicketController::class, 'store' ])->name('tickets.store');
Route::get('/create', [ TicketController::class, 'create' ])->name('tickets.create');
Route::prefix('{ticket}')->group(function () {
Route::get('/', [ TicketController::class, 'show' ])->name('tickets.show');
Route::post('/', [ TicketController::class, 'close' ])->name('tickets.close');
Route::post('/message', [ TicketController::class, 'message' ])->name('tickets.message');
Route::prefix('{ticketUpload}')->group(function () {
Route::get('/download', [ TicketController::class, 'download' ])->name('tickets.download');
Router::macro($routeMacroName, function ($controller) {
Route::middleware(config('laravel-tickets.guard'))->name('laravel-tickets.')->group(function () use ($controller) {
Route::prefix('/tickets')->group(function () use ($controller) {
Route::get('/', [ $controller, 'index' ])->name('tickets.index');
Route::post('/', [ $controller, 'store' ])->name('tickets.store');
Route::get('/create', [ $controller, 'create' ])->name('tickets.create');
Route::prefix('{ticket}')->group(function () use ($controller) {
Route::get('/', [ $controller, 'show' ])->name('tickets.show');
Route::post('/', [ $controller, 'close' ])->name('tickets.close');
Route::post('/message', [ $controller, 'message' ])->name('tickets.message');
Route::prefix('{ticketUpload}')->group(function () use ($controller) {
Route::get('/download', [ $controller, 'download' ])->name('tickets.download');
});
});
});
Expand Down

0 comments on commit c623e5e

Please sign in to comment.