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\Customer;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Product; use App\Models\Product;
use App\Models\Ticket;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\Rules\In; 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'));
}
} }

@ -18,26 +18,26 @@
background: var(--xshop-secondary); background: var(--xshop-secondary);
} }
*{ * {
font-family: 'Vazirmatn' , sans-serif; font-family: 'Vazirmatn', sans-serif;
} }
html { html {
scroll-behavior: smooth; scroll-behavior: smooth;
} }
body{ body {
background: var(--xshop-background); background: var(--xshop-background);
color: var(--xshop-text); color: var(--xshop-text);
overflow-x: hidden; overflow-x: hidden;
} }
#website-preloader{ #website-preloader {
transition: 500ms; transition: 500ms;
} }
.color-bullet{ .color-bullet {
width: 25px; width: 25px;
height: 25px; height: 25px;
margin: auto; margin: auto;
@ -45,7 +45,7 @@ body{
} }
#do-edit{ #do-edit {
position: fixed; position: fixed;
inset-inline-start: 0; inset-inline-start: 0;
top: 5%; top: 5%;
@ -56,35 +56,74 @@ body{
width: 50px; width: 50px;
opacity: .4; opacity: .4;
transition: 1s; transition: 1s;
&:hover{
&:hover {
opacity: 1; opacity: 1;
} }
i{
i {
font-size: 25px; font-size: 25px;
} }
} }
[id^="hidden-img"]{ [id^="hidden-img"] {
display: none; display: none;
} }
#hidden-images{
#hidden-images {
display: none; display: none;
} }
.color-bullet{ .color-bullet {
border-radius: 50%; border-radius: 50%;
width: 25px; width: 25px;
height: 25px; height: 25px;
border: 1px solid gray; border: 1px solid gray;
} }
#tabs-content{ #tabs-content {
.tab{ .tab {
display: none; display: none;
&.active{ &.active {
display: block;
}
}
}
#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; 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> </a>
</li> </li>
<li> <li>
<a href="#tickets"> <a href="#submit-ticket">
<i class="ri-mail-add-line"></i> <i class="ri-mail-add-line"></i>
{{__("Submit new ticket")}} {{__("Submit new ticket")}}
</a> </a>
@ -349,8 +349,41 @@
</div> </div>
<div class="tab" id="tickets"> <div class="tab" id="tickets">
<table class="table table-striped">
{{-- WIP tikets--}} <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>
<div class="tab" id="comments"> <div class="tab" id="comments">
@ -376,7 +409,28 @@
@endif @endif
</div> </div>
<div class="tab" id="submit-ticket"> <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>
<div class="tab" id="addresses"> <div class="tab" id="addresses">
<address-input <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::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::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('/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('/invoice/{invoice}', [\App\Http\Controllers\CustomerController::class, 'invoice'])->name('invoice');
Route::get('/products', [ClientController::class, 'products'])->name('products'); Route::get('/products', [ClientController::class, 'products'])->name('products');
Route::get('/attachments', [ClientController::class, 'attachments'])->name('attachments'); Route::get('/attachments', [ClientController::class, 'attachments'])->name('attachments');

Loading…
Cancel
Save