Claude Code Plugins

Community-maintained marketplace

Feedback

laravel-value-objects

@leeovery/claude-laravel
4
0

Immutable value objects for domain values. Use when working with domain values, immutable objects, or when user mentions value objects, immutable values, domain values, money objects, coordinate objects.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name laravel-value-objects
description Immutable value objects for domain values. Use when working with domain values, immutable objects, or when user mentions value objects, immutable values, domain values, money objects, coordinate objects.

Laravel Value Objects

Immutable value objects encapsulate domain values with validation and behavior.

Core Concept

value-objects.md - Value object patterns:

  • Immutable domain values
  • Static factory methods
  • Domain logic encapsulation
  • When to use vs DTOs
  • Comparison and equality

Pattern

final readonly class Money
{
    private function __construct(
        public int $amount,
        public string $currency,
    ) {}

    public static function fromCents(int $cents, string $currency = 'USD'): self
    {
        return new self($cents, $currency);
    }

    public static function fromDollars(float $dollars, string $currency = 'USD'): self
    {
        return new self((int) ($dollars * 100), $currency);
    }

    public function add(Money $other): self
    {
        if ($this->currency !== $other->currency) {
            throw new InvalidArgumentException('Currency mismatch');
        }

        return new self($this->amount + $other->amount, $this->currency);
    }
}

Value objects vs DTOs: Value objects have domain behavior and validation, DTOs are for data transfer.