laravel-eloquent

Configure Laravel models, relationships, scopes, casts, and eager loading.

Updated May 2, 2026
One-click install
npx skills add https://github.com/abdallhMoukdad/laravel-agent-skills --skill laravel-eloquent-abdallhmoukdad
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: laravel-eloquent
Source: https://github.com/abdallhMoukdad/laravel-agent-skills/tree/main/skills/laravel-eloquent
Command: npx skills add https://github.com/abdallhMoukdad/laravel-agent-skills --skill laravel-eloquent-abdallhmoukdad

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and scripts (resource) and assets (resource) components.

What problem does it solve?

This Skill helps developers efficiently work with Laravel's Eloquent ORM for defining models, relationships, scopes, and data casting. It addresses the challenge of maintaining consistent, secure, and optimized data interactions within Laravel applications.

Core Features & Use Cases

  • Model Configuration: Define fillable properties and data casts for models.
  • Relationship Management: Establish and optimize relationships like hasMany, belongsTo, and polymorphic associations.
  • Scopes and Query Optimization: Create global and local scopes, and perform efficient data retrieval with eager loading and query constraints.
  • Use Case: Quickly generate models with proper relationships and scopes to support robust API features in a Laravel backend.

Quick Start

Use the laravel-eloquent skill to define a model with fillable fields, relationships, and scopes for efficient querying.

Frequently Asked Questions about laravel-eloquent

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

FAQPage Schema
How do I optimize Laravel Eloquent queries to prevent N+1 relationship loading issues?▼

Laravel Eloquent query optimization prevents N+1 issues by applying eager loading to relationship configurations. Eager loading constraints retrieve associated models in a single query, ensuring efficient data handling and consistent ORM operations.

What is the best way to define Laravel model relationships and scopes for a robust backend API?▼

Defining Laravel model relationships and scopes for APIs involves establishing hasMany, belongsTo, and polymorphic associations alongside global and local scopes. This configuration optimizes data retrieval constraints to support consistent backend data handling.

Can I use Laravel Eloquent casts and fillable properties to ensure consistent data handling?▼

Laravel Eloquent casts and fillable properties ensure consistent data handling by automatically converting attribute data types and specifying mass-assignment fields. Model configuration defines these properties to maintain secure and optimized data interactions.

When do I need global and local scopes in Laravel Eloquent for query constraints?▼

Global and local scopes in Laravel Eloquent are needed when applying query constraints to data retrieval. Scopes allow developers to extract reusable query logic, ensuring consistent filtering conditions across model operations without duplicating code.

Does configuring Laravel polymorphic associations require special model and relationship setup?▼

Configuring Laravel polymorphic associations requires specific model and relationship setup to establish connections between different model types. Relationship management establishes these associations to optimize ORM operations and ensure consistent data handling across polymorphic structures.