laravel-eloquent

Implements Laravel 13 Eloquent ORM models using PHP 8.3 attributes, relationships, and query patterns.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill laravel-eloquent-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-eloquent
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/laravel-expert/skills/laravel-eloquent
Command: npx skills add https://github.com/fusengine/kimi-code --skill laravel-eloquent-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Working with Laravel 13's Eloquent ORM requires knowing the new PHP 8.3 attribute-based metadata syntax (#[Table], #[Fillable], #[Casts]) while avoiding legacy property conflicts, N+1 query problems, and lifecycle pitfalls like instantiating models in boot(). This Skill provides the complete attribute-first reference and templates so models, relationships, and queries are written correctly the first time. ## Core Features & Use Cases - Attribute-first model authoring: Covers #[Table], #[Fillable], #[Hidden], #[Casts], #[Appends], #[Touches], #[Connection], and #[Scope] with a full legacy-property migration mapping from Laravel 12. - Complete relationship and query coverage: Documents basic, many-to-many, advanced (hasOneThrough, ofMany), and polymorphic relationships plus eager loading, scopes, aggregates, pagination, and batch operations. - Lifecycle and output tooling: Includes observers/events, soft deletes, factories, API resources, transactions, serialization, and query debugging/performance guidance with ready-to-use PHP templates. - Use Case: When adding a new Post model with comments, tags, and published scopes, the Skill supplies the attribute-based model template, the morphToMany/belongsToMany relationship patterns, and eager-loading examples that prevent N+1 queries. ## Quick Start Ask the agent to create a Laravel 13 Eloquent model with attributes, relationships, and a factory for your chosen entity.

Frequently Asked Questions about laravel-eloquent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define fillable fields in Laravel 13 Eloquent models?▼

Use the #[Fillable(['name', 'email'])] PHP attribute on the model class instead of the legacy protected $fillable property. Never mix both on the same model, since the attribute is the single source of truth in Laravel 13.

How do I prevent N+1 queries in Laravel Eloquent?▼

Eager load relationships with with('relation') at query time, or use load() and loadMissing() after retrieval. In development, call Model::preventLazyLoading() to throw exceptions on lazy loading violations.

Can I still use $fillable and $casts properties in Laravel 13?▼

Yes, legacy properties remain fully supported for backward compatibility, but they are considered legacy style. New code should use PHP attributes like #[Fillable] and #[Casts], and you must never mix both styles for the same concern on one model.

Why does Laravel 13 throw LogicException when creating models in boot()?▼

Laravel 13 protects the model booting lifecycle, so instantiating a model with new Model() inside boot() or booted() throws a LogicException. Move such logic to service providers, factories, or runtime code instead.

How do I define a query scope in Laravel 13?▼

Add the #[Scope] attribute to a protected method that accepts a Builder, such as #[Scope] protected function published(Builder $query). Then call it fluently as Post::published()->get().

When should I use insert() versus create() for bulk records?▼

Use insert() or upsert() for bulk operations since they skip model events and run as single queries, but add timestamps manually. Use create() only when you need model events, observers, or automatic timestamps per record.