{"data":{"slug":"discovered-26b1153c811b90dd9a4e802367a2a8302b90a797f5f151a4","title":"Laravel Specialist","summary":"Build and configure Laravel 10+ applications, including creating Eloquent models and relationships, implementing Sanctum authentication, configuring Horizon queues, designing RESTful APIs with API resources, and building reactive interfaces with Livewire. Use when creating Laravel models, setting up queue workers, implementing Sanctum auth flows, building Livewire components, optimising Eloquent queries, or writing Pest\/PHPUnit tests for Laravel features.","url":"https:\/\/skillshunter.net\/skills\/discovered-26b1153c811b90dd9a4e802367a2a8302b90a797f5f151a4","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-26b1153c811b90dd9a4e802367a2a8302b90a797f5f151a4","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-26b1153c811b90dd9a4e802367a2a8302b90a797f5f151a4.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-26b1153c811b90dd9a4e802367a2a8302b90a797f5f151a4\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure PHP 8.2+ is installed and configured before running any commands. Run `php artisan make:model` to create models and verify with `php artisan migrate:status`. Write comprehensive tests with >85% coverage before considering any step complete.","instructions":"---\nname: laravel-specialist\ndescription: Build and configure Laravel 10+ applications, including creating Eloquent models and relationships, implementing Sanctum authentication, configuring Horizon queues, designing RESTful APIs with API resources, and building reactive interfaces with Livewire. Use when creating Laravel models, setting up queue workers, implementing Sanctum auth flows, building Livewire components, optimising Eloquent queries, or writing Pest\/PHPUnit tests for Laravel features.\nlicense: MIT\nmetadata:\n  author: https:\/\/github.com\/Jeffallan\n  company: https:\/\/synergetic.solutions\n  version: \"1.1.0\"\n  domain: backend\n  triggers: Laravel, Eloquent, PHP framework, Laravel API, Artisan, Blade templates, Laravel queues, Livewire, Laravel testing, Sanctum, Horizon\n  role: specialist\n  scope: implementation\n  output-format: code\n  related-skills: fullstack-guardian, test-master, devops-engineer, security-reviewer\n---\n\n# Laravel Specialist\n\nSenior Laravel specialist with deep expertise in Laravel 10+, Eloquent ORM, and modern PHP 8.2+ development.\n\n## Core Workflow\n\n1. **Analyse requirements** \u2014 Identify models, relationships, APIs, and queue needs\n2. **Design architecture** \u2014 Plan database schema, service layers, and job queues\n3. **Implement models** \u2014 Create Eloquent models with relationships, scopes, and casts; run `php artisan make:model` and verify with `php artisan migrate:status`\n4. **Build features** \u2014 Develop controllers, services, API resources, and jobs; run `php artisan route:list` to verify routing\n5. **Test thoroughly** \u2014 Write feature and unit tests; run `php artisan test` before considering any step complete (target >85% coverage)\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Eloquent ORM | `references\/eloquent.md` | Models, relationships, scopes, query optimization |\n| Routing & APIs | `references\/routing.md` | Routes, controllers, middleware, API resources |\n| Queue System | `references\/queues.md` | Jobs, workers, Horizon, failed jobs, batching |\n| Livewire | `references\/livewire.md` | Components, wire:model, actions, real-time |\n| Testing | `references\/testing.md` | Feature tests, factories, mocking, Pest PHP |\n\n## Constraints\n\n### MUST DO\n- Use PHP 8.2+ features (readonly, enums, typed properties)\n- Type hint all method parameters and return types\n- Use Eloquent relationships properly (avoid N+1 with eager loading)\n- Implement API resources for transforming data\n- Queue long-running tasks\n- Write comprehensive tests (>85% coverage)\n- Use service containers and dependency injection\n- Follow PSR-12 coding standards\n\n### MUST NOT DO\n- Use raw queries without protection (SQL injection)\n- Skip eager loading (causes N+1 problems)\n- Store sensitive data unencrypted\n- Mix business logic in controllers\n- Hardcode configuration values\n- Skip validation on user input\n- Use deprecated Laravel features\n- Ignore queue failures\n\n## Code Templates\n\nUse these as starting points for every implementation.\n\n### Backed Enum\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Enums;\n\nenum PostStatus: string\n{\n    case Draft = 'draft';\n    case Published = 'published';\n}\n```\n\n### Eloquent Model\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Models;\n\nuse App\\Enums\\PostStatus;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nfinal class Post extends Model\n{\n    use HasFactory, SoftDeletes;\n\n    protected $fillable = ['title', 'body', 'status', 'user_id'];\n\n    protected $casts = [\n        'status' => PostStatus::class, \/\/ backed enum\n        'published_at' => 'immutable_datetime',\n    ];\n\n    \/\/ Relationships \u2014 always eager-load via ::with() at call site\n    public function author(): BelongsTo\n    {\n        return $this->belongsTo(User::class, 'user_id');\n    }\n\n    public function comments(): HasMany\n    {\n        return $this->hasMany(Comment::class);\n    }\n\n    \/\/ Local scope\n    public function scopePublished(Builder $query): Builder\n    {\n        return $query->where('status', PostStatus::Published);\n    }\n}\n```\n\n### Migration\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n    public function up(): void\n    {\n        Schema::create('posts', function (Blueprint $table): void {\n            $table->id();\n            $table->foreignId('user_id')->constrained()->cascadeOnDelete();\n            $table->string('title');\n            $table->text('body');\n            $table->string('status')->default('draft');\n            $table->timestamp('published_at')->nullable();\n            $table->softDeletes();\n            $table->timestamps();\n        });\n    }\n\n    public function down(): void\n    {\n        Schema::dropIfExists('posts');\n    }\n};\n```\n\n### API Resource\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Http\\Resources;\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nfinal class PostResource extends JsonResource\n{\n    public function toArray(Request $request): array\n    {\n        return [\n            'id'           => $this->id,\n            'title'        => $this->title,\n            'body'         => $this->body,\n            'status'       => $this->status->value,\n            'published_at' => $this->published_at?->toIso8601String(),\n            'author'       => new UserResource($this->whenLoaded('author')),\n            'comments'     => CommentResource::collection($this->whenLoaded('comments')),\n        ];\n    }\n}\n```\n\n### Queued Job\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace App\\Jobs;\n\nuse App\\Enums\\PostStatus;\nuse App\\Models\\Post;\nuse Illuminate\\Bus\\Queueable;\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Foundation\\Bus\\Dispatchable;\nuse Illuminate\\Queue\\InteractsWithQueue;\nuse Illuminate\\Queue\\SerializesModels;\n\nfinal class PublishPost implements ShouldQueue\n{\n    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;\n\n    public int $tries = 3;\n    public int $backoff = 60;\n\n    public function __construct(\n        public readonly Post $post,\n    ) {}\n\n    public function handle(): void\n    {\n        $this->post->update([\n            'status'       => PostStatus::Published,\n            'published_at' => now(),\n        ]);\n    }\n\n    public function failed(\\Throwable $e): void\n    {\n        \/\/ Log or notify \u2014 never silently swallow failures\n        logger()->error('PublishPost failed', ['post' => $this->post->id, 'error' => $e->getMessage()]);\n    }\n}\n```\n\n### Feature Test (Pest)\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\nuse App\\Jobs\\PublishPost;\nuse App\\Models\\Post;\nuse App\\Models\\User;\nuse Illuminate\\Support\\Facades\\Queue;\n\nit('returns a published post for authenticated users', function (): void {\n    $user = User::factory()->create();\n    $post = Post::factory()->published()->for($user, 'author')->create();\n\n    $response = $this->actingAs($user)\n        ->getJson(\"\/api\/posts\/{$post->id}\");\n\n    $response->assertOk()\n        ->assertJsonPath('data.status', 'published')\n        ->assertJsonPath('data.author.id', $user->id);\n});\n\nit('queues a publish job when a draft is submitted', function (): void {\n    Queue::fake();\n    $user = User::factory()->create();\n    $post = Post::factory()->draft()->for($user, 'author')->create();\n\n    $this->actingAs($user)\n        ->postJson(\"\/api\/posts\/{$post->id}\/publish\")\n        ->assertAccepted();\n\n    Queue::assertPushed(PublishPost::class, fn (PublishPost $job) => $job->post->is($post));\n});\n```\n\n## Validation Checkpoints\n\nRun these at each workflow stage to confirm correctness before proceeding:\n\n| Stage | Command | Expected Result |\n|-------|---------|-----------------|\n| After migration | `php artisan migrate:status` | All migrations show `Ran` |\n| After routing | `php artisan route:list --path=api` | New routes appear with correct verbs |\n| After job dispatch | `php artisan queue:work --once` | Job processes without exception |\n| After implementation | `php artisan test --coverage` | >85% coverage, 0 failures |\n| Before PR | `.\/vendor\/bin\/pint --test` | PSR-12 linting passes |\n\n## Knowledge Reference\n\nLaravel 10+, Eloquent ORM, PHP 8.2+, API resources, Sanctum\/Passport, queues, Horizon, Livewire, Inertia, Octane, Pest\/PHPUnit, Redis, broadcasting, events\/listeners, notifications, task scheduling\n\nMaintained by [@jeffallan](https:\/\/github.com\/jeffallan), Principal Consultant at [Synergetic Solutions](https:\/\/synergetic.solutions)\n\n[Documentation](https:\/\/jeffallan.github.io\/claude-skills\/skills\/backend\/laravel-specialist\/)\n","use_cases":["Creating Laravel models with Eloquent relationships","Setting up queue workers with Horizon","Implementing Sanctum authentication flows","Building Livewire components for reactive interfaces","Optimizing Eloquent queries with eager loading","Writing Pest\/PHPUnit tests with >85% coverage"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/Jeffallan\/claude-skills\/blob\/a8be463010e2ca23afe00ea00773aea7128e8971\/plugin\/skills\/laravel-specialist\/SKILL.md","source_commit":"a8be463010e2ca23afe00ea00773aea7128e8971","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:47:22.000000Z","updated_at":"2026-11-29T10:53:15.000000Z","seo_title":"Laravel Specialist - Build and Configure Laravel Applications","seo_description":"Expert in Laravel 10+ development, including Eloquent models, Sanctum authentication, Horizon queues, RESTful APIs, and Livewire components.","seo_keywords":["Laravel","Eloquent","PHP framework","Laravel API","Artisan","Blade templates","Laravel queues","Livewire"]}}