@extends('layout.mainlayout') @section('content')
@component('components.breadcrumb') @slot('title') Ticket #{{ $ticket->id }} Details @endslot @endcomponent @if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif @if ($errors->any())
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
{{-- Left column: core ticket info --}}

#{{ $ticket->id }} — {{ $ticket->subject }}

Created {{ $ticket->created_at?->format('d M Y H:i') }}
{{ $ticket->status }} @if (!empty($ticket->priority))
{{ $ticket->priority }} Priority
@endif
Raised By
{{ $ticket->user->name ?? '—' }} @if ($ticket->user?->email)
{{ $ticket->user->email }}
@endif
Phone
{{ $ticket->user_phone ?? '—' }}
Location
{{ $ticket->location->name ?? ($ticket->location_name ?? '—') }}
Project
{{ $ticket->project->name ?? ($ticket->project_name ?? '—') }}
Department
{{ $ticket->department->name ?? '—' }}
Assignee
{{ $ticket->assignee->name ?? '—' }} @if ($ticket->assignee?->email)
{{ $ticket->assignee->email }}
@endif
Resolver
{{ $ticket->resolver->name ?? '—' }} @if ($ticket->resolver?->email)
{{ $ticket->resolver->email }}
@endif
TAT / Due
{{ $ticket->tat_due_at ? $ticket->tat_due_at->format('d M Y H:i') : '—' }}
Attachment
@if (!empty($ticket->attachment_path)) View / Download @else — @endif

Ticket Details

{{ $ticket->details }}

{{-- Right column: actions + update log --}}
@php $currentUserId = Auth::id(); $isAssignee = $currentUserId === $ticket->assignee_id; $isResolver = $currentUserId === $ticket->resolver_id; $canAssign = Auth::user()->can('ticket-assign'); $canResolve = Auth::user()->can('ticket-resolve'); // showActionGroup: only assignee/resolver or privileged staff $showActionGroup = $isAssignee || $isResolver || $canAssign || $canResolve; @endphp {{-- Actions card: Accept / Add Update / Change Status --}}
Actions
{{-- 1) Accept (only visible to assigned resolver or users with resolve permission) --}} @can('accept', $ticket) @if ($ticket->status !== 'IN_PROGRESS')
@csrf
@endif @endcan {{-- 2) Add Update (comment + optional attachment) - VISIBLE ONLY TO staff (assignee/resolver/privileged), NOT OWNER --}} @if ($showActionGroup)
@csrf
@endif {{-- 3) Change Status (generic) - VISIBLE ONLY TO staff (assignee/resolver/privileged), NOT OWNER --}} @if ($showActionGroup)
@csrf
@endif {{-- 4) Quick Resolve button (optional) - visible only to resolver or users with resolve perm --}} @if ($isResolver || $canResolve)
@csrf
@endif {{-- 5) Reopen & Escalate: show to owner via @can (policy controls) --}}
@can('reopen', $ticket) @if(in_array($ticket->status, ['RESOLVED','CLOSED']))
@csrf
@endif @endcan @can('escalate', $ticket) @if(!in_array($ticket->status, ['CLOSED','ESCALATED']))
@csrf
@endif @endcan
{{-- Ticket history / log --}}
Ticket Activity Log
@if ($ticket->updates->isEmpty())

No updates yet.

@else
    @foreach ($ticket->updates->sortByDesc('created_at') as $log)
  • {{ $log->user->name ?? 'System' }} {{ $log->created_at?->format('d M Y H:i') }}
    @if ($log->old_status || $log->new_status)
    Status: {{ $log->old_status ?? '—' }} → {{ $log->new_status ?? '—' }}
    @endif @if ($log->priority_from || $log->priority_to)
    Priority: {{ $log->priority_from ?? '—' }} → {{ $log->priority_to ?? '—' }}
    @endif @if ($log->tat_due_at)
    TAT set to: {{ \Carbon\Carbon::parse($log->tat_due_at)->format('d M Y H:i') }}
    @endif @if ($log->comment)
    {{ $log->comment }}
    @endif @if (!empty($log->attachment_path)) @endif
  • @endforeach
@endif
@endsection