diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 2c1b406..5f418b8 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -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')); + } + } diff --git a/resources/sass/client-custom/_general.scss b/resources/sass/client-custom/_general.scss index 632e22e..b47178a 100644 --- a/resources/sass/client-custom/_general.scss +++ b/resources/sass/client-custom/_general.scss @@ -18,26 +18,26 @@ background: var(--xshop-secondary); } -*{ - font-family: 'Vazirmatn' , sans-serif; +* { + font-family: 'Vazirmatn', sans-serif; } html { scroll-behavior: smooth; } -body{ +body { background: var(--xshop-background); color: var(--xshop-text); overflow-x: hidden; } -#website-preloader{ +#website-preloader { transition: 500ms; } -.color-bullet{ +.color-bullet { width: 25px; height: 25px; margin: auto; @@ -45,7 +45,7 @@ body{ } -#do-edit{ +#do-edit { position: fixed; inset-inline-start: 0; top: 5%; @@ -56,35 +56,74 @@ body{ width: 50px; opacity: .4; transition: 1s; - &:hover{ + + &:hover { opacity: 1; } - i{ + + i { font-size: 25px; } } -[id^="hidden-img"]{ +[id^="hidden-img"] { display: none; } -#hidden-images{ + +#hidden-images { display: none; } -.color-bullet{ +.color-bullet { border-radius: 50%; width: 25px; height: 25px; border: 1px solid gray; } -#tabs-content{ - .tab{ +#tabs-content { + .tab { 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; + 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); + } +} diff --git a/resources/views/client/ticket.blade.php b/resources/views/client/ticket.blade.php new file mode 100644 index 0000000..0816165 --- /dev/null +++ b/resources/views/client/ticket.blade.php @@ -0,0 +1,84 @@ +@extends('website.inc.website-layout') + +@section('title') + {{$ticket->title}} - {{config('app.name')}} +@endsection +@section('content') +
+
+ + + {{__("Back to profile")}} + +

+ {{$ticket->title}} +

+
+
+ +
+
+ {{__("You")}} +
+ {{$ticket->body}} + + {{$ticket->created_at->ldate('Y-m-d H:i')}} + +
+ @if($ticket->answer != null) +
+
+ {{$ticket->user->name}} +
+ {{$ticket->answer}} + + {{$ticket->created_at->ldate('Y-m-d H:i')}} + +
+ @endif +
+ @foreach($ticket->subTickets as $t) +
+ +
+
+ {{__("You")}} +
+ {{$t->body}} + + {{$t->created_at->ldate('Y-m-d H:i')}} + +
+ @if($t->answer != null) +
+
+ {{$ticket->user->name}} +
+ {{$t->answer}} + + {{$t->updated_at->ldate('Y-m-d H:i')}} + +
+ @endif +
+ @endforeach +
+
+
+ @csrf +
+ + +
+
+ +
+
+
+
+@endsection diff --git a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php index 171fee9..43989d9 100644 --- a/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php +++ b/resources/views/segments/customer/AvisaCustomer/AvisaCustomer.blade.php @@ -48,7 +48,7 @@
  • - + {{__("Submit new ticket")}} @@ -349,8 +349,41 @@
    - - {{-- WIP tikets--}} + + + + + + + + @foreach(auth('customer')->user()->main_tickets()->orderByDesc('id')->get() as $i => $ticket) + + + + + + + @endforeach +
    + # + + {{__("Title")}} + + {{__("Status")}} + + - +
    + {{$i+1}} + + {{$ticket->title}} + + {{__($ticket->status)}} + + + + {{__("View")}} + +
    @@ -376,7 +409,28 @@ @endif
    - {{-- WIP submit new ticket --}} +
    + @csrf +
    + + +
    +
    + + +
    +
    + +
    +
    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');