← ClaudeAtlas

laravel-8-noteslisted

Laravel 8.x (September 2020) signature features and the breaking-change traps from 7 → 8. Use when writing or reviewing code in a Laravel 8 project, or in a package whose composer constraint includes ^8.0. Covers the factory class rewrite (HasFactory trait), Jetstream/Fortify scaffolding split, job batching, queueable closures, the app/Models/ relocation, dynamic Blade components, migration squashing, and the Tailwind-by-default switch.
hmj1026/dhpk · ★ 1 · AI & Automation · score 72
Install: claude install-skill hmj1026/dhpk
# Laravel 8 — factories rewritten, job batching, models relocated Released September 2020. PHP 7.3+ floor. Lots of structural change in this release — the biggest since 5.0. --- ## Signature features ### Factory class rewrite (the big one) Before 8.0: ```php // database/factories/UserFactory.php — closure-based $factory->define(User::class, function (Faker $faker) { return [ 'name' => $faker->name, 'email' => $faker->unique()->safeEmail, ]; }); // Usage factory(User::class)->create(); factory(User::class, 3)->create(); ``` After 8.0: ```php // database/factories/UserFactory.php — class-based final class UserFactory extends Factory { protected $model = User::class; public function definition(): array { return [ 'name' => $this->faker->name, 'email' => $this->faker->unique()->safeEmail, ]; } public function suspended(): self { return $this->state(fn () => ['status' => 'suspended']); } } // In the User model: use Illuminate\Database\Eloquent\Factories\HasFactory; final class User extends Authenticatable { use HasFactory; } // Usage User::factory()->create(); User::factory()->count(3)->suspended()->create(); ``` Class-based factories enable **states** (named variants like `suspended()`), **relationship sequences**, and inheritance. They're also more discoverable in IDEs. > **Upgrade trap**: the global `factory()` helper still exists via > `laravel/legacy-factories`