{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "marcreichel-laya-php--store-decisions-in-json-column",
 "repo": "marcreichel/laya-php",
 "repo_url": "https://github.com/marcreichel/laya-php",
 "repo_slug": "marcreichel-laya-php",
 "title": "Save typed decisions in an Eloquent JSON column",
 "page_title": "How to save typed decisions in an Eloquent JSON column with Laya PHP",
 "summary": "Cast a model attribute to a decision class so the result reads back as a typed object.",
 "who": "A Laravel developer who wants to keep each classification result on the record it describes, without writing parsing code.",
 "problem": "Storing classification output as loose arrays loses the enum and type information, and every read needs manual conversion.",
 "outcome": "The model attribute holds a typed decision, and it reads back with enums and floats intact.",
 "steps": [
  "Run `composer require marcreichel/laya-php` in your Laravel app.",
  "Add `'triage' => AsDecision::of(Triage::class)` to the model's `casts()` method, with a JSON column named `triage`.",
  "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."
 ],
 "agent_prompt": "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.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "45 minutes",
 "basis": "readme",
 "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.",
 "category": "Work and operations",
 "tags": [
  "Work and operations"
 ],
 "lang": "php",
 "requirements": [
  "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)"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.7,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/marcreichel-laya-php/store-decisions-in-json-column/",
 "md": "https://dedupedai.com/use-cases/marcreichel-laya-php/store-decisions-in-json-column/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/marcreichel-laya-php--store-decisions-in-json-column.json",
 "api_version": "v1"
}
