laravel-models

Structure and maintain Laravel Eloquent models with relationships, casts, and observers.

1|Updated May 24, 2026
One-click install
npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-models-ptkdrake
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-models
Source: https://github.com/PTKDrake/FIT-vmu/tree/main/.agents/skills/laravel-models
Command: npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-models-ptkdrake

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides guidelines and best practices for creating and managing Eloquent models in Laravel, addressing common challenges in database layer and domain entity representation.

Core Features & Use Cases

  • Model Structure: Offers best practices for defining models, relationships, casts, and observers.
  • Casts: Explains how to use casts for type safety and JSON column casting.
  • Model Methods: Discusses acceptable helper methods and the dangers of including business logic.
  • Model Observers: Provides information on using observers for model lifecycle hooks.
  • Model Concerns: Shows how to extract reusable behavior into concerns.
  • Route Model Binding: Explains how to use implicit and custom key binding for routes.
  • Mass Assignment Protection: Outlines the importance of unguarding models and the reasons behind it.
  • Model Organization: Suggests a structured directory layout for model files and concerns.
  • Testing Models: Offers testing strategies for ensuring model functionality.

Quick Start

Use the laravel-models skill to review the structure of your Order model and ensure it follows best practices.

Frequently Asked Questions about laravel-models

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

FAQPage Schema
How do I structure Laravel Eloquent models to separate business logic?

To separate business logic in Laravel Eloquent models, you should define acceptable helper methods while avoiding direct business logic implementation, utilize model observers for lifecycle hooks, and extract reusable behavior into model concerns.

What is the best way to manage mass assignment protection in Laravel Eloquent?

The best practice for mass assignment in Laravel Eloquent involves unguarding models. This approach requires understanding the specific reasons behind unguarding to ensure database security and maintainability while handling bulk data operations.

How do I use casts in Laravel Eloquent for type safety?

You use casts in Laravel Eloquent to enforce type safety on model attributes. This mechanism includes JSON column casting, allowing you to automatically convert stored database values into native PHP types during retrieval and interaction.

Does Laravel Eloquent support custom route model binding?

Yes, Laravel Eloquent supports route model binding through both implicit and custom key binding. This feature allows you to automatically resolve database records from route parameters, streamlining controller logic and request handling.

What are the testing strategies for Laravel Eloquent models?

Testing strategies for Laravel Eloquent models focus on verifying model functionality and relationships. These strategies ensure that your database layer and domain entity representations perform correctly across various application states and operations.