← ClaudeAtlas

laravel-7-noteslisted

Laravel 7.x (March 2020) signature features and the breaking-change traps from 6 → 7. Use when writing or reviewing code in a Laravel 7 project, or in a package whose composer constraint includes ^7.0. Covers the new HTTP client facade, custom Eloquent casts via the CastsAttributes interface, the Blade x-component overhaul, Symfony 5 upgrade implications, and route-model-binding-by-key.
hmj1026/dhpk · ★ 1 · AI & Automation · score 72
Install: claude install-skill hmj1026/dhpk
# Laravel 7 — HTTP client, custom casts, blade components Released March 2020. **6-month support cycle** (not LTS). PHP 7.2.5+ floor. --- ## Signature features ### HTTP client wrapper (Http facade) ```php $response = Http::withHeaders(['X-Trace' => $traceId]) ->retry(3, 100) ->timeout(5) ->post('https://api.example.com/orders', ['sku' => $sku]); if ($response->successful()) { $order = $response->json('data'); } ``` Wraps Guzzle with a fluent Laravel API. Notable: built-in retry, timeout, response mocking via `Http::fake()`. Strongly preferred over direct Guzzle in new Laravel 7+ code — it integrates with Laravel's logging, dump-and-die helpers, and test fakes. ### Custom Eloquent casts ```php final class MoneyCast implements CastsAttributes { public function get($model, string $key, $value, array $attributes): Money { return Money::fromCents((int) $value); } public function set($model, string $key, $value, array $attributes): array { return [$key => $value instanceof Money ? $value->cents() : (int) $value]; } } // In the model: protected $casts = ['price' => MoneyCast::class]; ``` Before 7.0: accessor/mutator methods (`getPriceAttribute`, `setPriceAttribute`) were the only path. CastsAttributes is cleaner for value-object wrapping — reusable across models, testable in isolation. ### Blade `x-component` syntax ```blade {{-- resources/views/components/alert.blade.php --}} <div class="alert alert-{{ $type }}">