Subviews and @once

Including Subviews, @once, and Raw PHP

@include renders another view, which sees its parent's variables plus any array you pass. A missing view throws, so @includeIf skips one, @includeWhen and @includeUnless take a condition, and @includeFirst uses the first view that exists. @once emits its body once per render, @php runs statements, and @use imports a class:

resources/views/products/includes.blade.phpSass
@use('Illuminate\Support\Number')
@php($total = $products->sum('stock'))
@include('partials.stock-row', ['product' => $products->first()])
@includeWhen($total > 10, 'partials.banner', ['text' => 'Big stock!'])
@includeIf('partials.promo')
@includeFirst(['theme.stock-row', 'partials.stock-row'], ['product' => $products->last()])
@foreach ($products as $product)
  @once <link rel="stylesheet" href="/css/cards.css"> @endonce
@endforeach
Units: {{ Number::format($total) }}
Output
each: #1 stock 12
banner: Big stock!
each: #3 stock 0
   <link rel="stylesheet" href="/css/cards.css">     Units: 15

The missing views were skipped or replaced, and the <link> printed once for three books; @once compiles to a check on a UUID generated at compile time (hasRenderedOnce('70442439-...')).