laravel-model

Generate Laravel Eloquent models with relationships, casts, and factories.

Updated Jan 11, 2026
One-click install
npx skills add https://github.com/AdemKao/ai-cowork --skill laravel-model
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-model
Source: https://github.com/AdemKao/ai-cowork/tree/main/.ai/stacks/php-laravel/skills/model
Command: npx skills add https://github.com/AdemKao/ai-cowork --skill laravel-model

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel projects often require boilerplate models with consistent relationships, casts, and factories, leading to repetitive boilerplate and potential inconsistencies.

Core Features & Use Cases

  • Define Eloquent relationships (hasMany, belongsTo, belongsToMany, etc.) and ensure proper typing.
  • Configure attribute casts, fillable properties, and default values for predictable behavior.
  • Generate a ready-to-use factory, and provide a clean template for migrations and queries across entities.

Quick Start

Create a new Laravel model for a given entity, including relationships, casts, and a basic factory.

Frequently Asked Questions about laravel-model

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

FAQPage Schema
How do I create Laravel Eloquent models with relationships and casts?

To create Laravel Eloquent models with relationships and casts, you can use a scaffolding template that automatically defines hasMany or belongsTo relations, configures attribute casts, and generates matching factories for consistent boilerplate.

What's the best way to generate Laravel model factories and migrations together?

The best way to generate Laravel model factories and migrations together is by using a dedicated scaffolding process that builds your Eloquent model, attaches a ready-to-use factory, and provides a clean migration template.

Why does my Laravel model return uncasted database attributes?

Your Laravel model returns uncasted database attributes when the casts array is not properly configured. Defining attribute casts and fillable properties ensures predictable behavior and correct type casting for your Eloquent entities.

Do I need a PHP development environment to scaffold Laravel models?

Yes, you need a PHP development environment with Laravel's Eloquent installed to scaffold Laravel models. This setup is required to properly generate model templates with migrations, relations, and query scopes.

Can I define belongsToMany relationships and query scopes in a standard Laravel web application?

Yes, you can define belongsToMany relationships and query scopes in a standard Laravel web application. Scaffolding tools apply proper typing to Eloquent relations and provide clean templates for consistent query scoping across entities.