@php /** @var \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Collection $messages */ $messages = $messages ?? collect(); $users = $users ?? collect(); $responsibleUserIds = array_map('intval', $responsibleUserIds ?? []); $managerUserId = isset($managerUserId) ? (int) $managerUserId : null; $brigadierUserId = isset($brigadierUserId) ? (int) $brigadierUserId : null; $currentUserId = (int) auth()->id(); $contextKey = $contextKey ?? 'chat'; $title = $title ?? 'Чат'; $submitLabel = $submitLabel ?? 'Отправить'; $canCreateMessages = $canCreateMessages ?? true; $canSendNotifications = $canCreateMessages && ($canSendNotifications ?? hasPermission('chat_messages.notify')); $canDeleteMessages = ($canDeleteMessages ?? hasAnyPermission(['orders.chat.delete', 'reclamations.chat.delete'])) && !empty($action); $notificationValue = old('notification_type', \App\Models\ChatMessage::NOTIFICATION_NONE); $notificationEnabled = $canSendNotifications && $notificationValue !== \App\Models\ChatMessage::NOTIFICATION_NONE; $showAllUsers = $notificationValue === \App\Models\ChatMessage::NOTIFICATION_ALL; $selectedTargetUserIds = collect(old('target_user_ids', [])) ->map(static fn ($id) => (int) $id) ->filter() ->unique() ->values() ->all(); $sortedUsers = $users->sortBy('name'); @endphp