InstaRefi

Great News, {{ $user->name ?? '' }} may qualify to

@php $propertyName = $data['property_name'] ?? null; $m = $data['mdata'] ?? null; $mortgageInfo = $data['mortgage_info'] ?? null; // Prefer explicitly passed current_estimated_home_value (from property), // but fall back to mdata if it happens to contain this field. $currentEstimatedHomeValue = $data['current_estimated_home_value'] ?? ($m->current_estimated_home_value ?? null); @endphp @if($alertType === 'take_cash_out')

Get Cash-Out

${{ number_format($data['potential_cash_out_value'] ?? 0, 2) }}

@elseif($alertType === 'lower_rate_same_term')

Lower Your Payment

@if($m)

{{ number_format($m->proposed_interest_rate ?? 0, 3) }}% / {{ number_format($data['annual_purchase_rate'] ?? 0, 3) }}% APR

@endif @elseif($alertType === 'lower_rate_not_same_term')

Lower Interest Cost

@if($m)

{{ number_format($m->proposed_interest_rate ?? 0, 3) }}% / {{ number_format($data['annual_purchase_rate'] ?? 0, 3) }}% APR

@endif @elseif($alertType === 'remove_mortgage_insurance')

Remove Mortgage Insurance

@if($m)

{{ number_format($m->proposed_interest_rate ?? 0, 3) }}% / {{ number_format($data['annual_purchase_rate'] ?? 0, 3) }}% APR

@endif @else

{{ ucfirst(str_replace('_', ' ', $alertType)) }}

@endif @if($propertyName)

{{ $propertyName }}

@endif @if($alertType === 'take_cash_out' && $m)

Home Equity ${{ number_format(($m->current_estimated_home_value - $m->current_loan_balance), 2) }}

@elseif(in_array($alertType, ['lower_rate_same_term', 'lower_rate_not_same_term', 'remove_mortgage_insurance']))

@if(!empty($data['emi_monthly_saving'])) Monthly Payment Saving ${{ number_format($data['emi_monthly_saving'] ?? 0, 2) }} @endif @if($alertType === 'lower_rate_not_same_term' && !empty($data['interest_saving']))

Total Interest Saving ${{ number_format($data['interest_saving'] ?? 0, 2) }} @endif

@endif
@if($alertType === 'take_cash_out') House Icon @elseif($alertType === 'lower_rate_same_term') House Icon @elseif($alertType === 'lower_rate_not_same_term') House Icon @elseif($alertType === 'remove_mortgage_insurance') House Icon @else House Icon @endif
@if($propertyName)

{{ $propertyName }}

@endif

Estimated Property Value

@if(!is_null($currentEstimatedHomeValue))

${{ number_format($currentEstimatedHomeValue, 2) }}

@endif

{{-- Key loan metrics summary (two-column table like design screenshot) --}} @if($m || $mortgageInfo || !empty($data['property_type']) || !empty($data['occupancy'])) @php $originalLoanAmount = $m->original_loan_balance ?? null; $currentLoanBalance = $m->current_loan_balance ?? ($data['current_loan_balance'] ?? null); $creditScore = $mortgageInfo->estimated_credit_score ?? null; $pmiValue = $mortgageInfo->monthly_pmi_payment ?? $m->current_mortgage_insurance_payment_monthly ?? null; // Prefer values coming from the main mdata/mortgage_info payload, // but fall back to the property-level attributes that are always // included in the loan officer email payload. $occupancy = $m->occupancy ?? $mortgageInfo->occupancy ?? $mortgageInfo->occupancyType ?? ($data['occupancy'] ?? null); $propertyType = $m->property_type ?? $mortgageInfo->property_type ?? ($data['property_type'] ?? null); $mortgageStartDate = $m->mortgage_start_date ?? $mortgageInfo->mortgage_start_date ?? null; $currentRate = $m->current_interest_rate ?? $mortgageInfo->current_interest_rate ?? null; @endphp
Original Loan Amount  @if(!is_null($originalLoanAmount)) ${{ number_format($originalLoanAmount, 2) }} @else N/A @endif Credit Score  {{ $creditScore ?? 'N/A' }}
Current Loan Balance  @if(!is_null($currentLoanBalance)) ${{ number_format($currentLoanBalance, 2) }} @else N/A @endif PMI  ${{ number_format($pmiValue ?? 0, 2) }}
Property Type  @if($propertyType || $occupancy) @if(in_array($alertType, ['lower_rate_not_same_term', 'lower_rate_same_term', 'take_cash_out', 'remove_mortgage_insurance'])) {{ $occupancy ?? 'N/A' }} @else {{ $propertyType ?? 'N/A' }} @if($occupancy)  ({{ $occupancy }}) @endif @endif @else N/A @endif Mortgage Start Date:  @if($mortgageStartDate) {{ \Carbon\Carbon::parse($mortgageStartDate)->format('M Y') }} @else N/A @endif
Current Loan Rate  @if(!is_null($currentRate)) {{ $currentRate }}% @else N/A @endif  
@endif

EXISTING LOAN DETAILS

@php $monthlyPaymentExisting = $m->current_monthly_payment ?? $m->current_mortgage_payment_monthly ?? $data['current_monthly_payment'] ?? null; $loanTermExisting = $m->loan_term ?? $mortgageInfo->loan_term ?? null; $loanTermYearsExisting = $loanTermExisting ? (int) round($loanTermExisting / 12) : null; $interestRemainingExisting = $m->interest_remaining_on_current_loan ?? $data['interest_remaining_on_current_loan'] ?? null; @endphp @if($alertType === 'lower_rate_same_term') @php // Existing loan program (LRST only): // - Prefer the program stored on the main mortgage_info record // - Fall back to any explicitly passed loan_program // - Finally, use `mortgageTypes` which mirrors the value sent to LenderPrice $loanProgramExisting = ($mortgageInfo->loan_program ?? null) ?? ($data['loan_program'] ?? null) ?? ($data['mortgageTypes'] ?? null); // Existing loan type (LRST only): // - Prefer the type stored on the main mortgage_info record // - Fall back to any explicitly passed loan_type $loanTypeExisting = ($mortgageInfo->loan_type ?? null) ?? ($data['loan_type'] ?? null); @endphp @if($monthlyPaymentExisting || $loanTermExisting || $interestRemainingExisting || $loanProgramExisting || $loanTypeExisting)
Monthly Payment (P&I)  @if(!is_null($monthlyPaymentExisting)) ${{ number_format($monthlyPaymentExisting, 2) }} @else N/A @endif Loan Program  {{ $loanProgramExisting ?? 'N/A' }}
Term  @if(!is_null($loanTermYearsExisting)) {{ $loanTermYearsExisting }} yr @elseif(!is_null($loanTermExisting)) {{ $loanTermExisting }} months @else N/A @endif Loan Type  @if($alertType === 'take_cash_out') {{ $data['mortgageTypes'] ?? 'N/A' }} @else {{ $loanTypeExisting ?? 'N/A' }} @endif
Interest Remaining  @if(!is_null($interestRemainingExisting)) ${{ number_format($interestRemainingExisting, 2) }} @else N/A @endif  
@endif @else @php // Original behavior for all other alerts (including lower_rate_not_same_term): // Only "Loan Type" is shown and derived from LenderPrice mortgageTypes or DB loan_type. $loanTypeExisting = $data['mortgageTypes'] ?? $mortgageInfo->loan_type ?? ($data['loan_type'] ?? null); @endphp @if($monthlyPaymentExisting || $loanTermExisting || $interestRemainingExisting || $loanTypeExisting)
Monthly Payment (P&I)  @if(!is_null($monthlyPaymentExisting)) ${{ number_format($monthlyPaymentExisting, 2) }} @else N/A @endif Loan Type  @if(in_array($alertType, ['take_cash_out', 'remove_mortgage_insurance'])) {{ $mortgageInfo->loan_program ?? 'N/A' }} @else {{ $loanTypeExisting ?? 'N/A' }} @endif
Term  @if(!is_null($loanTermYearsExisting)) {{ $loanTermYearsExisting }} yr @elseif(!is_null($loanTermExisting)) {{ $loanTermExisting }} months @else N/A @endif    
Interest Remaining  @if(!is_null($interestRemainingExisting)) ${{ number_format($interestRemainingExisting, 2) }} @else N/A @endif  
@endif @endif

{{-- Show PROPOSED LOAN DETAILS only for rate / MI alerts --}} @if(in_array($alertType, ['lower_rate_same_term', 'lower_rate_not_same_term', 'remove_mortgage_insurance']))

PROPOSED LOAN DETAILS

@php $proposedMonthlyPayment = $m->proposed_mortgage_payment_monthly ?? ($data['proposed_mortgage_payment_monthly'] ?? null); // Prefer explicit proposed term, but gracefully fall back to generic loan_term $proposedTerm = $m->proposed_term ?? $m->loan_term ?? ($data['proposed_term'] ?? ($data['loan_term'] ?? null)); $proposedTermYears = $proposedTerm ? (int) round($proposedTerm / 12) : null; // Loan type for proposed offer: $apiResponse = $data['api_response'] ?? null; $lpMortgageType = null; if ($apiResponse && isset($apiResponse->lender_price)) { $lp = $apiResponse->lender_price; if (is_array($lp)) { $lpMortgageType = $lp['mortgageType'] ?? null; } else { $lpMortgageType = $lp->mortgageType ?? null; } } $proposedLoanType = $lpMortgageType ?? $data['mortgageTypes'] ?? ($data['loan_type'] ?? null); $proposedInterest = $data['interest_to_be_paid_for_new_loan'] ?? null; $monthlySaving = $data['emi_monthly_saving'] ?? null; $totalInterestSaving = $data['interest_saving'] ?? null; $costOrCredit = $m->cost_or_credit ?? null; @endphp @if($proposedMonthlyPayment || $proposedTerm || $proposedLoanType || $proposedInterest || $monthlySaving || $totalInterestSaving || $costOrCredit)
Proposed Monthly Payment (P&I)  @if(!is_null($proposedMonthlyPayment)) ${{ number_format($proposedMonthlyPayment, 2) }} @else N/A @endif Proposed Terms  @if(!is_null($proposedTermYears)) {{ $proposedTermYears }} yr @elseif(!is_null($proposedTerm)) {{ $proposedTerm }} months @else N/A @endif
Proposed Loan Type  @if(in_array($alertType, ['remove_mortgage_insurance'])) {{ $mortgageInfo->loan_program ?? 'N/A' }} @else {{ $proposedLoanType ?? 'N/A' }} @endif Proposed Interest  @if(!is_null($proposedInterest)) ${{ number_format($proposedInterest, 2) }} @else N/A @endif
Monthly Saving  @if(!is_null($monthlySaving)) ${{ number_format($monthlySaving, 2) }} @else N/A @endif Total Interest Saving  @if(!is_null($totalInterestSaving)) ${{ number_format($totalInterestSaving, 2) }} @else N/A @endif
Cost/Credit  @if(!is_null($costOrCredit)) ${{ number_format(round($costOrCredit), 2) }} @else N/A @endif  
@endif @endif {{-- POTENTIAL CASH-OUT block for cash-out alerts --}} @if($alertType === 'take_cash_out')

POTENTIAL CASH-OUT

@php $cashOutAmount = $data['potential_cash_out_value'] ?? null; @endphp
Cash Out Amount @if(!is_null($cashOutAmount)) ${{ number_format($cashOutAmount, 2) }} @else N/A @endif
@endif

Borrower Details

{{ $user->name ?? 'N/A' }}

Email: {{ $user->email ?? 'N/A' }} Phone: {{ $user->mobile ?? 'N/A' }}