models

Create and manage Eloquent models with relationships, scopes, factories, and multi-tenancy.

1|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/aronpc/ai --skill models-aronpc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: models
Source: https://github.com/aronpc/ai/tree/main/skills/models
Command: npx skills add https://github.com/aronpc/ai --skill models-aronpc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Eloquent models are the foundation of Laravel data access, enabling clean representation of entities and their relationships across modules.

Core Features & Use Cases

  • Relational mappings (belongsTo, hasMany, etc.) and nested relationships
  • Scoped queries (local and global) and reusability through factories
  • Multi-tenancy awareness via tenant-aware patterns and scopes
  • Accessors, mutators, and casts for data shaping and validation
  • Soft deletes and event hooks to manage lifecycle changes
  • Practical examples for architecture with thin models and rich domain logic delegated to actions

Quick Start

Define a basic Product model with relationships and a global TenantScope to enforce tenant isolation.

Frequently Asked Questions about models

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

FAQPage Schema
How do I implement multi-tenancy in Laravel Eloquent models?

Multi-tenancy in Laravel Eloquent models is implemented using a global TenantScope to enforce tenant isolation automatically. This ensures consistent tenant-aware data access across typical application modules without manual filtering on every query.

What is the best way to structure Laravel Eloquent relationships and scopes?

Structuring Laravel Eloquent relationships and scopes involves defining relational mappings like belongsTo and hasMany alongside local and global scoped queries. This keeps data access reusable and maintains clean representation of nested entities.

How do I use accessors, mutators, and casts in Laravel models?

Accessors, mutators, and casts in Laravel models shape and validate data during retrieval and persistence. They align with robust model design by transforming attributes automatically before interacting with the database.

Can I use factories and soft deletes together in Laravel Eloquent?

Factories and soft deletes can be used together in Laravel Eloquent to support test data generation and lifecycle management. Soft deletes manage restoration capabilities, while factories provide reusable test data creation for scoped models.

When should I delegate domain logic away from Eloquent models in Laravel?

Domain logic should be delegated away from Eloquent models in Laravel when maintaining thin models for architecture. Delegating rich domain logic to action classes prevents bloated models and keeps lifecycle event hooks manageable.