@php use App\Models\RefundRequest; use Illuminate\Support\Str; $messages = $refund->messages ->sortBy(function ($message) { return $message->created_at ?? $message->id; }) ->values(); $refundStatus = match (true) { (bool) $refund->is_completed => [ 'label' => __('Completed'), 'class' => 'bg-success', 'icon' => 'fa-check-circle', ], (int) $refund->status === RefundRequest::STATUS_ACCEPTED => [ 'label' => __('Accepted'), 'class' => 'bg-info', 'icon' => 'fa-thumbs-up', ], (int) $refund->status === RefundRequest::STATUS_DECLINED => [ 'label' => __('Declined'), 'class' => 'bg-danger', 'icon' => 'fa-times-circle', ], default => [ 'label' => __('Pending'), 'class' => 'bg-warning text-dark', 'icon' => 'fa-clock', ], }; $canMessage = (bool) ( $availableActions['can_message'] ?? ! $refund->is_completed ); @endphp
{{-- Messages --}}
{{ __('Refund Conversation') }}
{{ $messages->count() }} {{ Str::plural(__('message'), $messages->count()) }}
@forelse($messages as $message) @php $isCurrentUser = ( (int) $message->user_id === (int) auth()->id() ); $senderName = $message->user?->username ?? ( $message->is_buyer ? __('Buyer') : __('Seller') ); $initials = Str::upper( Str::substr( trim((string) $senderName), 0, 2 ) ); $senderRole = $message->is_buyer ? __('Buyer') : ( $isCurrentUser ? __('Administrator') : __('Seller') ); $avatarClass = $message->is_buyer ? 'bg-warning text-dark' : ( $isCurrentUser ? 'bg-primary text-white' : 'bg-info text-white' ); @endphp
{{ $initials !== '' ? $initials : '?' }}
{{ $senderName }}
{{ $message->message }}
@if($message->created_at) {{ $message->created_at->format( 'M d, Y H:i' ) }} @endif {{ $senderRole }}
@empty
{{ __('No messages yet') }}

{{ __('The refund conversation will appear here.') }}

@endforelse
{{-- Message Form --}} @if($canMessage)
@csrf
@error('message')
{{ $message }}
@enderror
0 / 5,000
@else
{{ __('This refund has been completed and can no longer receive messages.') }}
@endif
{{-- Refund Information --}}
{{ __('Refund Information') }}
{{ __('Status') }}
{{ $refundStatus['label'] }}
{{ __('Refund ID') }}
#{{ $refund->id }}
@if($refund->order_number)
{{ __('Order') }}
{{ $refund->order_number }}
@endif
{{ __('Total Messages') }}
{{ $messages->count() }}
{{ __('Requested') }}
@if($refund->created_at) {{ $refund->created_at->diffForHumans() }} @else {{ __('N/A') }} @endif
@if($refund->updated_at)
{{ __('Last Updated') }}
{{ $refund->updated_at->diffForHumans() }}
@endif @if($refund->completed_at)
{{ __('Completed') }}
{{ $refund->completed_at->diffForHumans() }}
@endif @if($refund->refund_reference)
{{ __('Reference') }}
{{ $refund->refund_reference }}
@endif
{{-- Participants --}}
{{ __('Participants') }}
{{ __('Buyer') }}
{{ $refund->buyer?->username ?? __('Buyer #:id', [ 'id' => $refund->buyer_id, ]) }}
@if($refund->buyer?->email) {{ $refund->buyer->email }} @endif
{{ __('Seller') }}
{{ $refund->seller?->username ?? __('Seller #:id', [ 'id' => $refund->seller_id, ]) }}
@if($refund->seller?->email) {{ $refund->seller->email }} @endif
@push('styles') @endpush @push('scripts') @endpush