Email workspaceInsurance order status update
Source: App\Mail\InsuranceOrderStatusChanged, app/Mail/InsuranceOrderStatusChanged.php; resources/views/emails/insurance/order_status_changed.blade.php using mail::message. Subject: Your insurance order status changed! (unchanged). Suggested preheader: Your insurance order status changed from {{previous_status}} to {{current_status}}.
Portable values and exact branches
| Token | Existing source | Handling |
|---|---|---|
| {{first_name}} | user.first_name ?? '', user explicitly bound to order.user | Optional escaped greeting. Remove the whole marked greeting if empty/null; preserve nonempty 0. |
| {{previous_status}} | Constructor previousStatus captured before update | Required original status text, not inferred from activity/history. |
| {{current_status}} | order.status | Required original current status text; no prettified/guessed approval result. |
| {{cancellation_reason}} | order.reason | Required row only when order.status == 'cancelled'. Preserve empty/0 when supplied; do not test reason truthiness to select the branch. |
| {{policy_id}} | order.policy?->policy_id ?? 'N/A' | Required only when status == 'completed'. Null relation/ID becomes N/A, empty string/0 remains as supplied. Not order ID, UUID or a generated policy number. |
| {{app_name}} | config('app.name') | Original Thanks sign-off. |
| {{preheader}} | Source status-transition summary above | Escaped text with no timing/coverage/payment promise. |
Ready HTML/text have independently marked cancelled-reason and completed-policy sections. Keep exactly the section selected by the original status comparison, or neither for generic statuses. No reason leaks into completed/confirmed; no policy ID leaks into cancelled/other branches. The original status values and named policy identifier remain inside the email. There is no workflow URL, attachment/PDF or legacy duplicate link to invent. Default logo/optional {{logo_url}} and shared PNG/CID/HTTPS requirements: [shared-footer](../shared-footer.md).
Trigger, recipient and workflow
InsuranceOrderController::changeStatus (:164–214), route POST insurance-orders/{id}/change-status (routes/api.php:224), rejects changes to completed/cancelled orders and validates allowed transitions. Pending allows confirmed/cancelled; confirmed allows completed/cancelled; its generic/default path accepts the existing listed states. Cancellation requires reason. Completion requires policy_id/start_at and may upload policy documents. Do not change validation or infer that every renderer fixture is a valid transition/new order.
changeState (:216–295) captures previousState, updates order/activity transactionally, handles provider notification on confirmed, creates/updates NewInsurancePolicy plus documents/period on completed and stores reason on cancelled. It then queues this Mailable to order.user.email with native internal BCC at :277; SMS follows separately. Preserve all state/record/document ordering and native recipient/error behavior. A different previous status and one Mailable do not constitute additional notification types.
build() binds order, user and previousStatus. No explicit From/Reply-To override exists; preserve configured headers, exact subject, To/BCC and queue()/transport behavior. Policy files/coverage dates stored by the controller are not attached or linked in this email and do not justify new PDF/download/expiry claims. Completed is the source status, not a new standalone guarantee of coverage eligibility, settlement or a refund.
Integration and safety
Prefer the existing Mailable with a complete HTML Blade view and proposed plain-text alternative. Portable {{placeholder_name}} tokens are not automatically Blade expressions. Keep native conditions/relationships, escape all status/reason/ID text and attributes, validate logo/images separately and use one pass for replacement. No raw provider/merchant HTML, new framework, generated policy ID or app action belongs here. Missing required status/model context needs an explicit target-project decision.
Nine states cover confirmed, cancelled, cancellation reason 0, completed, N/A policy fallback, empty policy ID as a view check, generic branch/empty greeting and long cancellation/policy values. Source validation may reject empty values for new updates; renderer robustness does not change that. Files: public/ready/insurance-order-status.html/.txt and previews/insurance-order-status-*.html/.txt. No separate project-owned per-email text source found. Browser rendering does not establish a real policy's state/coverage, document/CID delivery, actual email-client compatibility or current production sending.