@php $expenseTransaction = $plan->transactions ->where('type', $type) ->where('direction', TransactionDirection::EXPENSE) ->when(isset($clientId), fn($query) => $query->where('client_id', $clientId) ) ->first(); if(! $expenseTransaction) { return; } @endphp