Files
SealShare/.claude/skills/laravel-best-practices/rules/blade-views.md
T
Andreas Reinhold / reiniandClaude Opus 4.8 4391ad7fb9 Regenerate Boost guidelines and skills
Byproduct of the Laravel 13 upgrade: composer's post-update-cmd runs
`artisan boost:update`, and Boost went 2.1.3 to 2.4.x with the update.

Refreshes CLAUDE.md and boost.json for the Laravel 13 / Livewire 4 stack,
updates the livewire, pest and tailwindcss skills, replaces the
developing-with-fortify skill with fortify-development, and adds new
laravel-best-practices and octane-development skills.

Generated output, not hand-edited.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 11:17:04 +02:00

1.2 KiB

Blade & Views Best Practices

Use $attributes->merge() in Component Templates

Hardcoding classes prevents consumers from adding their own. merge() combines class attributes cleanly.

<div {{ $attributes->merge(['class' => 'alert alert-'.$type]) }}>
    {{ $message }}
</div>

Use @pushOnce for Per-Component Scripts

If a component renders inside a @foreach, @push inserts the script N times. @pushOnce guarantees it's included exactly once.

Prefer Blade Components Over @include

@include shares all parent variables implicitly (hidden coupling). Components have explicit props, attribute bags, and slots.

Use View Composers for Shared View Data

If every controller rendering a sidebar must pass $categories, that's duplicated code. A View Composer centralizes it.

Use Blade Fragments for Partial Re-Renders (htmx/Turbo)

A single view can return either the full page or just a fragment, keeping routing clean.

return view('dashboard', compact('users'))
    ->fragmentIf($request->hasHeader('HX-Request'), 'user-list');

Use @aware for Deeply Nested Component Props

Avoids re-passing parent props through every level of nested components.