added ticket control customer profile

pull/49/head
A1Gard 3 months ago
parent 5437e5f44b
commit 3abd1b6d38

@ -6,6 +6,7 @@ use App\Models\Address;
use App\Models\Customer;
use App\Models\Invoice;
use App\Models\Product;
use App\Models\Ticket;
use Illuminate\Http\Request;
use Illuminate\Validation\Rules\In;
@ -167,5 +168,41 @@ class CustomerController extends Controller
}
public function submitTicket(Request $request){
$request->validate([
'title' => ['required', 'string', 'max:255'],
'body' => ['required', 'string'],
]);
$ticket = new Ticket();
$ticket->title = $request->title;
$ticket->body = trim($request->body);
$ticket->customer_id = auth('customer')->user()->id;
$ticket->save();
return redirect()->route('client.profile')->with('message', __('Ticket added successfully'));
}
public function showTicket(Ticket $ticket){
return view('client.ticket',compact('ticket'));
}
public function ticketAnswer(Ticket $ticket, Request $request){
$request->validate([
'body' => ['required', 'string'],
]);
$ticket->status = "PENDING";
$ticket->save();
$nticket = new Ticket();
$nticket->parent_id = $ticket->id;
$nticket->body = trim($request->body);
$nticket->customer_id = auth('customer')->user()->id;
$nticket->save();
return redirect(route('client.profile').'#tickets')->with('message', __('Ticket answered successfully'));
}
}

@ -56,9 +56,11 @@ body{
width: 50px;
opacity: .4;
transition: 1s;
&:hover {
opacity: 1;
}
i {
font-size: 25px;
}
@ -67,6 +69,7 @@ body{
[id^="hidden-img"] {
display: none;
}
#hidden-images {
display: none;
}
@ -88,3 +91,39 @@ body{
}
}
}
#ticket-content {
padding: 2rem;
h1 {
font-size: 24px;
}
.overflow-hidden {
margin-bottom: 1rem;
}
.t-answer, .t-message {
width: 45%;
padding: 1rem;
border-radius: var(--xshop-border-radius);
.t-time {
opacity: .5;
display: block;
text-align: end;
margin-top: 7px;
}
}
.t-message {
background: var(--xshop-primary);
color: var(--xshop-diff);
}
.t-answer {
background: var(--xshop-secondary);
color: var(--xshop-diff2);
}
}

@ -0,0 +1,84 @@
@extends('website.inc.website-layout')
@section('title')
{{$ticket->title}} - {{config('app.name')}}
@endsection
@section('content')
<main>
<div class="{{gfx()['container']}}" id="ticket-content">
<a href="{{route('client.profile')}}" class="btn btn-primary float-end">
<i class="ri-arrow-go-back-line"></i>
{{__("Back to profile")}}
</a>
<h1>
{{$ticket->title}}
</h1>
<div class="clearfix"></div>
<div class="overflow-hidden">
<div class="t-message">
<h6>
{{__("You")}}
</h6>
{{$ticket->body}}
<span class="t-time">
{{$ticket->created_at->ldate('Y-m-d H:i')}}
</span>
</div>
@if($ticket->answer != null)
<div class="t-answer float-end">
<h6>
{{$ticket->user->name}}
</h6>
{{$ticket->answer}}
<span class="t-time">
{{$ticket->created_at->ldate('Y-m-d H:i')}}
</span>
</div>
@endif
</div>
@foreach($ticket->subTickets as $t)
<div class="overflow-hidden">
<div class="t-message">
<h6>
{{__("You")}}
</h6>
{{$t->body}}
<span class="t-time">
{{$t->created_at->ldate('Y-m-d H:i')}}
</span>
</div>
@if($t->answer != null)
<div class="t-answer float-end">
<h6>
{{$ticket->user->name}}
</h6>
{{$t->answer}}
<span class="t-time">
{{$t->updated_at->ldate('Y-m-d H:i')}}
</span>
</div>
@endif
</div>
@endforeach
<br>
<hr>
<form action="{{ route('client.ticket.answer', $ticket->id) }}" method="post">
@csrf
<div class="form-group mt-3">
<label for="body">
{{__("Answer")}}
</label>
<textarea rows="5" name="body" class="form-control" placeholder="{{__("Your answer ...")}}">{{old('body')}}</textarea>
</div>
<div class="mt-3">
<button class="btn btn-outline-primary w-100">
<i class="ri-send-plane-2-line"></i>
{{__("Send answer")}}
</button>
</div>
</form>
</div>
</main>
@endsection

@ -48,7 +48,7 @@
</a>
</li>
<li>
<a href="#tickets">
<a href="#submit-ticket">
<i class="ri-mail-add-line"></i>
{{__("Submit new ticket")}}
</a>
@ -349,8 +349,41 @@
</div>
<div class="tab" id="tickets">
{{-- WIP tikets--}}
<table class="table table-striped">
<tr>
<td>
#
</td>
<th>
{{__("Title")}}
</th>
<th>
{{__("Status")}}
</th>
<th class="text-center">
-
</th>
</tr>
@foreach(auth('customer')->user()->main_tickets()->orderByDesc('id')->get() as $i => $ticket)
<tr>
<td>
{{$i+1}}
</td>
<td>
{{$ticket->title}}
</td>
<td>
{{__($ticket->status)}}
</td>
<td class="text-center">
<a href="{{ route('client.ticket.show',$ticket->id) }}" class="btn btn-outline-primary btn-sm">
<i class="ri-eye-line"></i>
{{__("View")}}
</a>
</td>
</tr>
@endforeach
</table>
</div>
<div class="tab" id="comments">
@ -376,7 +409,28 @@
@endif
</div>
<div class="tab" id="submit-ticket">
{{-- WIP submit new ticket --}}
<form action="{{ route('client.ticket.submit') }}" method="post">
@csrf
<div class="form-group">
<label for="title">
{{__("Title")}}
</label>
<input type="text" id="title" name="title" value="{{old('title')}}" placeholder="{{__("Title")}}"
class="form-control">
</div>
<div class="form-group mt-3">
<label for="body">
{{__("Description Text")}}
</label>
<textarea rows="7" name="body" class="form-control" placeholder="{{__("Your message ...")}}">{{old('body')}}</textarea>
</div>
<div class="mt-3">
<button class="btn btn-outline-primary w-100">
<i class="ri-send-plane-2-line"></i>
{{__("Send ticket")}}
</button>
</div>
</form>
</div>
<div class="tab" id="addresses">
<address-input

@ -380,6 +380,9 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class])
Route::post('/address/update/{address}', [\App\Http\Controllers\CustomerController::class, 'addressUpdate'])->name('address.update');
Route::get('/address/destroy/{address}', [\App\Http\Controllers\CustomerController::class, 'addressDestroy'])->name('address.destroy');
Route::post('/profile/save', [\App\Http\Controllers\CustomerController::class, 'save'])->name('profile.save');
Route::post('/ticket/submit', [\App\Http\Controllers\CustomerController::class, 'submitTicket'])->name('ticket.submit');
Route::post('/ticket/answer/{ticket}', [\App\Http\Controllers\CustomerController::class, 'ticketAnswer'])->name('ticket.answer');
Route::get('/ticket/{ticket}', [\App\Http\Controllers\CustomerController::class, 'showTicket'])->name('ticket.show');
Route::get('/invoice/{invoice}', [\App\Http\Controllers\CustomerController::class, 'invoice'])->name('invoice');
Route::get('/products', [ClientController::class, 'products'])->name('products');
Route::get('/attachments', [ClientController::class, 'attachments'])->name('attachments');

Loading…
Cancel
Save