customer(); $block = SecurityBlock::query() ->where('uuid', $uuid) ->whereHas('instance', fn ($q) => $q->where('customer_id', $customer?->id)) ->first(); abort_if($block === null, 403); $block->release(auth()->user()); $this->dispatch('notify', message: __('security.blocks_released')); } public function render() { $customer = $this->customer(); $blocks = $customer ? SecurityBlock::query() ->whereHas('instance', fn ($q) => $q->where('customer_id', $customer->id)) ->orderByDesc('blocked_at') ->get() : collect(); // Aktiv/Verlauf wird hier gesplittet, nicht per zweiter Abfrage: // scopeActive() prueft dieselben zwei Felder, die die Menge schon in // der Hand haelt. return view('livewire.security', [ 'active' => $blocks->filter( fn (SecurityBlock $b) => $b->released_at === null && $b->expires_at->isFuture() )->values(), 'history' => $blocks->filter( fn (SecurityBlock $b) => $b->released_at !== null || $b->expires_at->isPast() )->values(), ]); } }