Who it is forA Laravel developer who wants to keep each classification result on the record it describes, without writing parsing code.
The problemStoring classification output as loose arrays loses the enum and type information, and every read needs manual conversion.
The outcomeThe model attribute holds a typed decision, and it reads back with enums and floats intact.
What you need first
- PHP 8.4+ and Composer
- A PSR-18 HTTP client such as Guzzle or Symfony HttpClient
- Docker, to run laya-serve from the repo's compose.yaml
- Laravel 13+ for the Laravel steps (service provider, artisan commands, validation rule, cast)
Steps
- Run
composer require marcreichel/laya-phpin your Laravel app. - Add
'triage' => AsDecision::of(Triage::class)to the model'scasts()method, with a JSON column namedtriage. - Assign the result with
$ticket->triage = $laya->decide($ticket->body, Triage::class);and call$ticket->save();. - Read a field back with
$ticket->triage->department;to confirm it returns the enum case.
Prompt for your agent
In the marcreichel/laya-php repo, add an AsDecision cast for <decision class> on the <model> model's <json column>. Save one decision, reload the model and report the stored JSON and the read-back enum value. Verify that assigning a non-decision value throws InvalidDecisionCastException.
Caveat. Null attributes are stored as null, and lists and floats round-trip, but a JSON value with a missing key or an unknown enum value throws an exception.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for marcreichel/laya-php and "Save typed decisions in an Eloquent JSON column"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer