fchis's picture
Upload train.jsonl with huggingface_hub
92a4c7e verified
Raw
History Blame Contribute Delete
175 kB
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"ProjectResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"name\",\n \"source\": \"name\"\n },\n {\n \"key\": \"status\",\n \"source\": \"status\"\n },\n {\n \"key\": \"deadline\",\n \"source\": \"deadline\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"members_count\",\n \"modifier\": \"whenCounted\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"members\",\n \"resource\": \"TeamMemberResource\",\n \"type\": \"collection\"\n },\n {\n \"key\": \"category\",\n \"resource\": \"CategoryResource\",\n \"type\": \"make\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\CategoryResource;\nuse App\\Http\\Resources\\TeamMemberResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass ProjectResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'name' => $this->name,\n 'status' => $this->status,\n 'deadline' => $this->whenNotNull($this->deadline),\n 'members_count' => $this->whenCounted('members'),\n 'members' => TeamMemberResource::collection($this->whenLoaded('members')),\n 'category' => CategoryResource::make($this->whenLoaded('category')),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreSubscriberRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"email\": [\n \"required\",\n \"email\",\n \"max:255\",\n \"unique:subscribers,email\"\n ],\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"status\": [\n \"required\",\n \"string\",\n \"in:active,unsubscribed\"\n ],\n \"subscribed_at\": [\n \"nullable\",\n \"date\"\n ]\n },\n \"unique_ignore_route_param\": null\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreSubscriberRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'email' => ['required', 'email', 'max:255', 'unique:subscribers,email'],\n 'name' => ['required', 'string', 'max:255'],\n 'status' => ['required', 'string', 'in:active,unsubscribed'],\n 'subscribed_at' => ['nullable', 'date'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"Author\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Author\",\n \"resource\": \"AuthorResource\",\n \"validation_mode\": \"inline\",\n \"eager_load\": [],\n \"paginate\": 15,\n \"store_rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"email\": [\n \"nullable\",\n \"email\",\n \"unique:authors,email\"\n ],\n \"bio\": [\n \"nullable\",\n \"string\"\n ],\n \"birth_year\": [\n \"nullable\",\n \"integer\",\n \"min:1800\",\n \"max:2010\"\n ]\n },\n \"update_rules\": {\n \"name\": [\n \"sometimes\",\n \"string\",\n \"max:255\"\n ],\n \"email\": [\n \"nullable\",\n \"email\",\n \"unique:authors,email\"\n ],\n \"bio\": [\n \"nullable\",\n \"string\"\n ],\n \"birth_year\": [\n \"nullable\",\n \"integer\",\n \"min:1800\",\n \"max:2010\"\n ]\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Resources\\AuthorResource;\nuse App\\Models\\Author;\nuse Illuminate\\Http\\Request;\n\nclass AuthorController extends Controller\n{\n public function index(Request $request)\n {\n $authors = Author::query()->paginate(15);\n\n return AuthorResource::collection($authors);\n }\n\n public function store(Request $request)\n {\n $data = $request->validate([\n 'name' => ['required', 'string', 'max:255'],\n 'email' => ['nullable', 'email', 'unique:authors,email'],\n 'bio' => ['nullable', 'string'],\n 'birth_year' => ['nullable', 'integer', 'min:1800', 'max:2010'],\n ]);\n\n $author = Author::create($data);\n\n return response()->json(new AuthorResource($author), 201);\n }\n\n public function show(Author $author)\n {\n return new AuthorResource($author);\n }\n\n public function update(Request $request, Author $author)\n {\n $data = $request->validate([\n 'name' => ['sometimes', 'string', 'max:255'],\n 'email' => ['nullable', 'email', 'unique:authors,email'],\n 'bio' => ['nullable', 'string'],\n 'birth_year' => ['nullable', 'integer', 'min:1800', 'max:2010'],\n ]);\n\n $author->update($data);\n\n return new AuthorResource($author);\n }\n\n public function destroy(Author $author)\n {\n $author->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"Event\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"venue_id\": [],\n \"event_date\": [\n \"required\",\n \"date\"\n ],\n \"status\": [\n \"nullable\",\n \"string\",\n \"in:draft,published,cancelled\"\n ],\n \"speaker_ids\": [\n \"nullable\",\n \"array\"\n ],\n \"speaker_ids.*\": [\n \"integer\",\n \"exists:speakers,id\"\n ]\n },\n \"conditional_rules\": {\n \"venue_id\": {\n \"POST\": [\n \"required\",\n \"integer\",\n \"exists:venues,id\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"integer\",\n \"exists:venues,id\"\n ]\n },\n \"event_date\": {\n \"POST\": [\n \"after:now\"\n ]\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreEventRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'title' => ['required', 'string', 'max:255'],\n 'description' => ['nullable', 'string'],\n 'venue_id' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'integer', 'exists:venues,id'],\n 'event_date' => ['required', 'date', ...$this->isMethod('POST') ? ['after:now'] : []],\n 'status' => ['nullable', 'string', 'in:draft,published,cancelled'],\n 'speaker_ids' => ['nullable', 'array'],\n 'speaker_ids.*' => ['integer', 'exists:speakers,id'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Book\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"books\",\n \"has_factory\": true,\n \"soft_deletes\": true,\n \"fillable\": [\n \"title\",\n \"isbn\",\n \"description\",\n \"author_id\",\n \"published_year\"\n ],\n \"casts\": {\n \"published_year\": \"integer\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"method\": \"author\",\n \"related\": \"Author\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Book extends Model\n{\n use HasFactory, SoftDeletes;\n\n protected $fillable = [\n 'title',\n 'isbn',\n 'description',\n 'author_id',\n 'published_year',\n ];\n\n protected function casts(): array\n {\n return [\n 'published_year' => 'integer',\n ];\n }\n\n public function author(): BelongsTo\n {\n return $this->belongsTo(Author::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Event\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"events\",\n \"has_factory\": true,\n \"soft_deletes\": true,\n \"fillable\": [\n \"title\",\n \"description\",\n \"venue_id\",\n \"event_date\",\n \"status\"\n ],\n \"casts\": {\n \"event_date\": \"datetime\",\n \"status\": \"string\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"method\": \"venue\",\n \"related\": \"Venue\"\n },\n {\n \"type\": \"BelongsToMany\",\n \"method\": \"speakers\",\n \"related\": \"Speaker\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Event extends Model\n{\n use HasFactory, SoftDeletes;\n\n protected $fillable = [\n 'title',\n 'description',\n 'venue_id',\n 'event_date',\n 'status',\n ];\n\n protected function casts(): array\n {\n return [\n 'event_date' => 'datetime',\n 'status' => 'string',\n ];\n }\n\n public function venue(): BelongsTo\n {\n return $this->belongsTo(Venue::class);\n }\n\n public function speakers(): BelongsToMany\n {\n return $this->belongsToMany(Speaker::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"EventResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"title\",\n \"source\": \"title\"\n },\n {\n \"key\": \"description\",\n \"source\": \"description\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"event_date\",\n \"source\": \"event_date\"\n },\n {\n \"key\": \"status\",\n \"source\": \"status\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"venue\",\n \"resource\": \"VenueResource\",\n \"type\": \"make\"\n },\n {\n \"key\": \"speakers\",\n \"resource\": \"SpeakerResource\",\n \"type\": \"collection\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\SpeakerResource;\nuse App\\Http\\Resources\\VenueResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass EventResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'title' => $this->title,\n 'description' => $this->whenNotNull($this->description),\n 'event_date' => $this->event_date,\n 'status' => $this->status,\n 'venue' => VenueResource::make($this->whenLoaded('venue')),\n 'speakers' => SpeakerResource::collection($this->whenLoaded('speakers')),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"Article\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"body\": [\n \"required\",\n \"string\"\n ],\n \"category_id\": [],\n \"published_at\": [\n \"nullable\",\n \"date\"\n ],\n \"slug\": []\n },\n \"conditional_rules\": {\n \"category_id\": {\n \"POST\": [\n \"required\",\n \"integer\",\n \"exists:categories,id\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"integer\",\n \"exists:categories,id\"\n ]\n },\n \"slug\": {\n \"POST\": [\n \"required\",\n \"string\",\n \"max:100\",\n \"unique:articles,slug\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"string\",\n \"max:100\"\n ]\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreArticleRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'title' => ['required', 'string', 'max:255'],\n 'body' => ['required', 'string'],\n 'category_id' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'integer', 'exists:categories,id'],\n 'published_at' => ['nullable', 'date'],\n 'slug' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'string', 'max:100', ...$this->isMethod('POST') ? ['unique:articles,slug'] : []],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreUserRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"email\": [\n \"required\",\n \"email\",\n \"max:255\",\n \"unique:users,email\"\n ],\n \"password\": [\n \"required\",\n \"string\",\n \"min:8\"\n ],\n \"role\": [\n \"nullable\",\n \"string\",\n \"in:admin,editor,viewer\"\n ]\n },\n \"unique_ignore_route_param\": \"user\"\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass StoreUserRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'name' => ['required', 'string', 'max:255'],\n 'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')->ignore($this->route('user'))],\n 'password' => ['required', 'string', 'min:8'],\n 'role' => ['nullable', 'string', 'in:admin,editor,viewer'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"Category\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Category\",\n \"resource\": \"CategoryResource\",\n \"validation_mode\": \"inline\",\n \"eager_load\": [],\n \"paginate\": 20,\n \"filters\": [\n \"status\"\n ],\n \"store_rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"status\": [\n \"required\",\n \"string\",\n \"in:active,inactive\"\n ],\n \"parent_id\": [\n \"nullable\",\n \"integer\",\n \"exists:categories,id\"\n ]\n },\n \"update_rules\": {\n \"name\": [\n \"sometimes\",\n \"string\",\n \"max:255\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"status\": [\n \"sometimes\",\n \"string\",\n \"in:active,inactive\"\n ],\n \"parent_id\": [\n \"nullable\",\n \"integer\",\n \"exists:categories,id\"\n ]\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Resources\\CategoryResource;\nuse App\\Models\\Category;\nuse Illuminate\\Http\\Request;\n\nclass CategoryController extends Controller\n{\n public function index(Request $request)\n {\n $categories = Category::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->paginate(20);\n\n return CategoryResource::collection($categories);\n }\n\n public function store(Request $request)\n {\n $data = $request->validate([\n 'name' => ['required', 'string', 'max:255'],\n 'description' => ['nullable', 'string'],\n 'status' => ['required', 'string', 'in:active,inactive'],\n 'parent_id' => ['nullable', 'integer', 'exists:categories,id'],\n ]);\n\n $category = Category::create($data);\n\n return response()->json(new CategoryResource($category), 201);\n }\n\n public function show(Category $category)\n {\n return new CategoryResource($category);\n }\n\n public function update(Request $request, Category $category)\n {\n $data = $request->validate([\n 'name' => ['sometimes', 'string', 'max:255'],\n 'description' => ['nullable', 'string'],\n 'status' => ['sometimes', 'string', 'in:active,inactive'],\n 'parent_id' => ['nullable', 'integer', 'exists:categories,id'],\n ]);\n\n $category->update($data);\n\n return new CategoryResource($category);\n }\n\n public function destroy(Category $category)\n {\n $category->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Invoice\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"invoices\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"number\",\n \"amount\",\n \"currency\",\n \"status\",\n \"customer_id\",\n \"due_at\"\n ],\n \"casts\": {\n \"amount\": \"decimal:2\",\n \"due_at\": \"datetime\"\n },\n \"relationships\": [],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Invoice extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'number',\n 'amount',\n 'currency',\n 'status',\n 'customer_id',\n 'due_at',\n ];\n\n protected function casts(): array\n {\n return [\n 'amount' => 'decimal:2',\n 'due_at' => 'datetime',\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"SubscriberResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"email\",\n \"source\": \"email\"\n },\n {\n \"key\": \"name\",\n \"source\": \"name\"\n },\n {\n \"key\": \"status\",\n \"source\": \"status\"\n },\n {\n \"key\": \"subscribed_at\",\n \"source\": \"subscribed_at\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n },\n {\n \"key\": \"updated_at\",\n \"source\": \"updated_at\"\n }\n ],\n \"loaded_relations\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass SubscriberResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'email' => $this->email,\n 'name' => $this->name,\n 'status' => $this->status,\n 'subscribed_at' => $this->whenNotNull($this->subscribed_at),\n 'created_at' => $this->created_at,\n 'updated_at' => $this->updated_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"OrderResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"status\",\n \"source\": \"status\"\n },\n {\n \"key\": \"total\",\n \"source\": \"total\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"customer\",\n \"resource\": \"CustomerResource\",\n \"type\": \"make\"\n },\n {\n \"key\": \"items\",\n \"resource\": \"OrderItemResource\",\n \"type\": \"collection\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\CustomerResource;\nuse App\\Http\\Resources\\OrderItemResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass OrderResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'status' => $this->status,\n 'total' => $this->total,\n 'customer' => CustomerResource::make($this->whenLoaded('customer')),\n 'items' => OrderItemResource::collection($this->whenLoaded('items')),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Subscriber\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"subscribers\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"email\",\n \"name\",\n \"status\",\n \"subscribed_at\"\n ],\n \"casts\": {\n \"subscribed_at\": \"datetime\",\n \"status\": \"string\"\n },\n \"relationships\": [],\n \"scopes\": [\n {\n \"name\": \"active\",\n \"column\": \"status\",\n \"value\": \"active\"\n },\n {\n \"name\": \"unsubscribed\",\n \"column\": \"status\",\n \"value\": \"unsubscribed\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Subscriber extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'email',\n 'name',\n 'status',\n 'subscribed_at',\n ];\n\n protected function casts(): array\n {\n return [\n 'subscribed_at' => 'datetime',\n 'status' => 'string',\n ];\n }\n\n public function scopeActive($query)\n {\n return $query->where('status', 'active');\n }\n\n public function scopeUnsubscribed($query)\n {\n return $query->where('status', 'unsubscribed');\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreReviewRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"product_id\": [\n \"required\",\n \"integer\",\n \"exists:products,id\"\n ],\n \"rating\": [\n \"required\",\n \"integer\",\n \"min:1\",\n \"max:5\"\n ],\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"body\": [\n \"nullable\",\n \"string\"\n ]\n },\n \"unique_ignore_route_param\": null\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreReviewRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'product_id' => ['required', 'integer', 'exists:products,id'],\n 'rating' => ['required', 'integer', 'min:1', 'max:5'],\n 'title' => ['required', 'string', 'max:255'],\n 'body' => ['nullable', 'string'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Post\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"posts\",\n \"has_factory\": true,\n \"soft_deletes\": true,\n \"fillable\": [\n \"title\",\n \"body\",\n \"status\",\n \"user_id\",\n \"category_id\"\n ],\n \"casts\": {},\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"method\": \"user\",\n \"related\": \"User\"\n },\n {\n \"type\": \"BelongsTo\",\n \"method\": \"category\",\n \"related\": \"Category\"\n },\n {\n \"type\": \"HasMany\",\n \"method\": \"comments\",\n \"related\": \"Comment\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Post extends Model\n{\n use HasFactory, SoftDeletes;\n\n protected $fillable = [\n 'title',\n 'body',\n 'status',\n 'user_id',\n 'category_id',\n ];\n\n public function user(): BelongsTo\n {\n return $this->belongsTo(User::class);\n }\n\n public function category(): BelongsTo\n {\n return $this->belongsTo(Category::class);\n }\n\n public function comments(): HasMany\n {\n return $this->hasMany(Comment::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Article\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"articles\",\n \"has_factory\": true,\n \"soft_deletes\": true,\n \"fillable\": [\n \"title\",\n \"body\",\n \"slug\",\n \"status\",\n \"author_id\",\n \"published_at\"\n ],\n \"casts\": {\n \"published_at\": \"datetime\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"model\": \"Author\",\n \"method\": \"author\"\n },\n {\n \"type\": \"BelongsToMany\",\n \"model\": \"Tag\",\n \"method\": \"tags\",\n \"table\": \"article_tag\"\n }\n ],\n \"scopes\": [\n {\n \"name\": \"published\",\n \"column\": \"status\",\n \"value\": \"published\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Article extends Model\n{\n use HasFactory, SoftDeletes;\n\n protected $fillable = [\n 'title',\n 'body',\n 'slug',\n 'status',\n 'author_id',\n 'published_at',\n ];\n\n protected $casts = [\n 'published_at' => 'datetime',\n ];\n\n public function scopePublished($query)\n {\n return $query->where('status', 'published');\n }\n\n public function author(): BelongsTo\n {\n return $this->belongsTo(Author::class);\n }\n\n public function tags(): BelongsToMany\n {\n return $this->belongsToMany(Tag::class, 'article_tag');\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"AuthorResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"name\",\n \"source\": \"name\"\n },\n {\n \"key\": \"bio\",\n \"source\": \"bio\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"nationality\",\n \"source\": \"nationality\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"books\",\n \"resource\": \"BookResource\",\n \"type\": \"collection\"\n },\n {\n \"key\": \"books_count\",\n \"source\": \"books_count\",\n \"modifier\": \"whenCounted\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\BookResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass AuthorResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'name' => $this->name,\n 'bio' => $this->whenNotNull($this->bio),\n 'nationality' => $this->whenNotNull($this->nationality),\n 'books' => BookResource::collection($this->whenLoaded('books')),\n 'books_count' => $this->whenCounted('books'),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"pest_test\",\n \"class\": \"Product\",\n \"namespace\": \"Tests\\\\Feature\",\n \"model\": \"App\\\\Models\\\\Product\",\n \"endpoints\": [\n {\n \"method\": \"GET\",\n \"path\": \"/api/products\",\n \"action\": \"index\"\n },\n {\n \"method\": \"POST\",\n \"path\": \"/api/products\",\n \"action\": \"store\"\n },\n {\n \"method\": \"GET\",\n \"path\": \"/api/products/{id}\",\n \"action\": \"show\"\n },\n {\n \"method\": \"PUT\",\n \"path\": \"/api/products/{id}\",\n \"action\": \"update\"\n },\n {\n \"method\": \"DELETE\",\n \"path\": \"/api/products/{id}\",\n \"action\": \"destroy\"\n }\n ],\n \"filters\": [\n \"status\",\n \"category_id\"\n ],\n \"required_on_create\": [\n \"name\",\n \"sku\",\n \"price\"\n ]\n}"}, {"role": "assistant", "content": "<?php\nuse App\\Models\\Category;\nuse App\\Models\\Product;\n\ntest('GET /api/products returns paginated list', function () {\n Product::factory()->count(3)->create();\n $this->getJson('/api/products')\n ->assertOk()\n ->assertJsonCount(3, 'data');\n});\n\ntest('GET /api/products filters by status', function () {\n Product::factory()->create(['status' => 'active']);\n Product::factory()->create(['status' => 'inactive']);\n $this->getJson('/api/products?status=active')\n ->assertOk()\n ->assertJsonCount(1, 'data');\n});\n\ntest('POST /api/products creates a product', function () {\n $category = Category::factory()->create();\n $this->postJson('/api/products', [\n 'name' => 'Widget',\n 'sku' => 'WDG-001',\n 'price' => 9.99,\n 'category_id' => $category->id,\n ])->assertCreated()\n ->assertJsonPath('name', 'Widget');\n});\n\ntest('POST /api/products requires name, sku, price', function () {\n $this->postJson('/api/products', [])\n ->assertUnprocessable()\n ->assertJsonValidationErrors(['name', 'sku', 'price']);\n});\n\ntest('DELETE /api/products/:id deletes the product', function () {\n $product = Product::factory()->create();\n $this->deleteJson(\"/api/products/{$product->id}\")\n ->assertNoContent();\n $this->assertDatabaseMissing('products', ['id' => $product->id]);\n});"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"SubscriberController\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Subscriber\",\n \"model_namespace\": \"App\\\\Models\",\n \"resource\": \"SubscriberResource\",\n \"form_request\": \"StoreSubscriberRequest\",\n \"actions\": {\n \"index\": {\n \"paginate\": 15,\n \"filters\": [\n {\n \"param\": \"status\",\n \"column\": \"status\"\n }\n ],\n \"eager_load\": []\n },\n \"store\": {\n \"status_code\": 201,\n \"many_to_many\": null\n },\n \"show\": {\n \"eager_load\": []\n },\n \"update\": {\n \"many_to_many\": null\n },\n \"destroy\": {\n \"force_delete\": false\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StoreSubscriberRequest;\nuse App\\Http\\Resources\\SubscriberResource;\nuse App\\Models\\Subscriber;\nuse Illuminate\\Http\\Request;\n\nclass SubscriberController extends Controller\n{\n public function index(Request $request)\n {\n $subscribers = Subscriber::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->paginate(15);\n\n return SubscriberResource::collection($subscribers);\n }\n\n public function store(StoreSubscriberRequest $request)\n {\n $subscriber = Subscriber::create($request->validated());\n\n return response()->json(new SubscriberResource($subscriber), 201);\n }\n\n public function show(Subscriber $subscriber)\n {\n return new SubscriberResource($subscriber);\n }\n\n public function update(StoreSubscriberRequest $request, Subscriber $subscriber)\n {\n $subscriber->update($request->validated());\n\n return new SubscriberResource($subscriber);\n }\n\n public function destroy(Subscriber $subscriber)\n {\n $subscriber->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Contact\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"contacts\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"name\",\n \"email\",\n \"phone\",\n \"message\"\n ],\n \"casts\": {},\n \"relationships\": [],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Contact extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'name',\n 'email',\n 'phone',\n 'message',\n ];\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"BookController\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Book\",\n \"model_namespace\": \"App\\\\Models\",\n \"resource\": \"BookResource\",\n \"form_request\": \"StoreBookRequest\",\n \"actions\": {\n \"index\": {\n \"paginate\": 15,\n \"filters\": [\n {\n \"param\": \"status\",\n \"column\": \"status\"\n }\n ],\n \"eager_load\": [\n \"author\"\n ]\n },\n \"store\": {\n \"status_code\": 201,\n \"eager_load_after\": [\n \"author\"\n ],\n \"many_to_many\": null\n },\n \"show\": {\n \"eager_load\": [\n \"author\"\n ]\n },\n \"update\": {\n \"many_to_many\": null\n },\n \"destroy\": {\n \"force_delete\": false\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StoreBookRequest;\nuse App\\Http\\Resources\\BookResource;\nuse App\\Models\\Book;\nuse Illuminate\\Http\\Request;\n\nclass BookController extends Controller\n{\n public function index(Request $request)\n {\n $books = Book::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->with('author')\n ->paginate(15);\n\n return BookResource::collection($books);\n }\n\n public function store(StoreBookRequest $request)\n {\n $book = Book::create($request->validated());\n\n return response()->json(new BookResource($book->load('author')), 201);\n }\n\n public function show(Book $book)\n {\n return new BookResource($book->load('author'));\n }\n\n public function update(StoreBookRequest $request, Book $book)\n {\n $book->update($request->validated());\n\n return new BookResource($book->load('author'));\n }\n\n public function destroy(Book $book)\n {\n $book->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"InvoiceResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"invoice_no\",\n \"source\": \"invoice_no\"\n },\n {\n \"key\": \"amount\",\n \"source\": \"amount\"\n },\n {\n \"key\": \"due_date\",\n \"source\": \"due_date\"\n },\n {\n \"key\": \"status\",\n \"source\": \"status\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"client\",\n \"resource\": \"ClientResource\",\n \"type\": \"make\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\ClientResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass InvoiceResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'invoice_no' => $this->invoice_no,\n 'amount' => $this->amount,\n 'due_date' => $this->due_date,\n 'status' => $this->status,\n 'client' => ClientResource::make($this->whenLoaded('client')),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreBookRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"isbn\": [\n \"required\",\n \"string\",\n \"max:20\",\n \"unique:books,isbn\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"author_id\": [\n \"required\",\n \"integer\",\n \"exists:authors,id\"\n ],\n \"published_year\": [\n \"nullable\",\n \"integer\",\n \"min:1000\",\n \"max:2100\"\n ]\n },\n \"unique_ignore_route_param\": \"book\"\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass StoreBookRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'title' => ['required', 'string', 'max:255'],\n 'isbn' => ['required', 'string', 'max:20', Rule::unique('books', 'isbn')->ignore($this->route('book'))],\n 'description' => ['nullable', 'string'],\n 'author_id' => ['required', 'integer', 'exists:authors,id'],\n 'published_year' => ['nullable', 'integer', 'min:1000', 'max:2100'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"Post\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Post\",\n \"resource\": \"PostResource\",\n \"form_request\": \"StorePostRequest\",\n \"validation_mode\": \"form_request\",\n \"eager_load\": [\n \"author\",\n \"tags\"\n ],\n \"paginate\": 10,\n \"filters\": [\n \"status\"\n ],\n \"many_to_many\": {\n \"relation\": \"tags\",\n \"input_key\": \"tag_ids\"\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StorePostRequest;\nuse App\\Http\\Resources\\PostResource;\nuse App\\Models\\Post;\nuse Illuminate\\Http\\Request;\n\nclass PostController extends Controller\n{\n public function index(Request $request)\n {\n $posts = Post::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->with(['author', 'tags'])\n ->paginate(10);\n\n return PostResource::collection($posts);\n }\n\n public function store(StorePostRequest $request)\n {\n $data = collect($request->validated())->except(['tag_ids'])->toArray();\n $post = Post::create($data);\n $post->tags()->sync($request->input('tag_ids', []));\n\n return response()->json(new PostResource($post->load(['author', 'tags'])), 201);\n }\n\n public function show(Post $post)\n {\n return new PostResource($post->load(['author', 'tags']));\n }\n\n public function update(StorePostRequest $request, Post $post)\n {\n $data = collect($request->validated())->except(['tag_ids'])->toArray();\n $post->update($data);\n $post->tags()->sync($request->input('tag_ids', []));\n\n return new PostResource($post->load(['author', 'tags']));\n }\n\n public function destroy(Post $post)\n {\n $post->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"ReviewController\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Review\",\n \"model_namespace\": \"App\\\\Models\",\n \"resource\": \"ReviewResource\",\n \"form_request\": \"StoreReviewRequest\",\n \"validation_mode\": \"form_request\",\n \"actions\": {\n \"index\": {\n \"paginate\": 15,\n \"eager_load\": [\n \"product\"\n ]\n },\n \"store\": {\n \"status_code\": 201,\n \"eager_load_after\": [\n \"product\"\n ]\n },\n \"show\": {\n \"eager_load\": [\n \"product\"\n ]\n },\n \"update\": {},\n \"destroy\": {\n \"force_delete\": false\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StoreReviewRequest;\nuse App\\Http\\Resources\\ReviewResource;\nuse App\\Models\\Review;\nuse Illuminate\\Http\\Request;\n\nclass ReviewController extends Controller\n{\n public function index(Request $request)\n {\n $reviews = Review::query()\n ->with('product')\n ->paginate(15);\n\n return ReviewResource::collection($reviews);\n }\n\n public function store(StoreReviewRequest $request)\n {\n $review = Review::create($request->validated());\n\n return response()->json(new ReviewResource($review->load('product')), 201);\n }\n\n public function show(Review $review)\n {\n return new ReviewResource($review->load('product'));\n }\n\n public function update(StoreReviewRequest $request, Review $review)\n {\n $review->update($request->validated());\n\n return new ReviewResource($review);\n }\n\n public function destroy(Review $review)\n {\n $review->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"EventController\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Event\",\n \"model_namespace\": \"App\\\\Models\",\n \"resource\": \"EventResource\",\n \"form_request\": \"StoreEventRequest\",\n \"actions\": {\n \"index\": {\n \"paginate\": 10,\n \"filters\": [\n {\n \"param\": \"status\",\n \"column\": \"status\"\n }\n ],\n \"eager_load\": [\n \"venue\",\n \"speakers\"\n ]\n },\n \"store\": {\n \"status_code\": 201,\n \"many_to_many\": {\n \"relation\": \"speakers\",\n \"input_key\": \"speaker_ids\"\n },\n \"except_keys\": [\n \"speaker_ids\"\n ],\n \"eager_load_after\": [\n \"venue\",\n \"speakers\"\n ]\n },\n \"show\": {\n \"eager_load\": [\n \"venue\",\n \"speakers\"\n ]\n },\n \"update\": {\n \"many_to_many\": {\n \"relation\": \"speakers\",\n \"input_key\": \"speaker_ids\"\n },\n \"except_keys\": [\n \"speaker_ids\"\n ]\n },\n \"destroy\": {\n \"force_delete\": false\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StoreEventRequest;\nuse App\\Http\\Resources\\EventResource;\nuse App\\Models\\Event;\nuse Illuminate\\Http\\Request;\n\nclass EventController extends Controller\n{\n public function index(Request $request)\n {\n $events = Event::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->with(['venue', 'speakers'])\n ->paginate(10);\n\n return EventResource::collection($events);\n }\n\n public function store(StoreEventRequest $request)\n {\n $data = collect($request->validated())->except(['speaker_ids'])->toArray();\n $event = Event::create($data);\n $event->speakers()->sync($request->input('speaker_ids', []));\n\n return response()->json(new EventResource($event->load(['venue', 'speakers'])), 201);\n }\n\n public function show(Event $event)\n {\n return new EventResource($event->load(['venue', 'speakers']));\n }\n\n public function update(StoreEventRequest $request, Event $event)\n {\n $data = collect($request->validated())->except(['speaker_ids'])->toArray();\n $event->update($data);\n $event->speakers()->sync($request->input('speaker_ids', []));\n\n return new EventResource($event->load(['venue', 'speakers']));\n }\n\n public function destroy(Event $event)\n {\n $event->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"migration\",\n \"operation\": \"create\",\n \"table\": \"contacts\",\n \"columns\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"email\",\n \"type\": \"string\",\n \"unique\": true\n },\n {\n \"name\": \"phone\",\n \"type\": \"string\",\n \"nullable\": true\n },\n {\n \"name\": \"message\",\n \"type\": \"text\",\n \"nullable\": true\n }\n ],\n \"timestamps\": true,\n \"soft_deletes\": false\n}"}, {"role": "assistant", "content": "<?php\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n public function up(): void\n {\n Schema::create('contacts', function (Blueprint $table) {\n $table->id();\n $table->string('name');\n $table->string('email')->unique();\n $table->string('phone')->nullable();\n $table->text('message')->nullable();\n $table->timestamps();\n });\n }\n\n public function down(): void\n {\n Schema::dropIfExists('contacts');\n }\n};"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Post\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"posts\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"title\",\n \"body\",\n \"slug\",\n \"status\",\n \"user_id\"\n ],\n \"casts\": {},\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"model\": \"User\",\n \"method\": \"author\",\n \"foreign_key\": \"user_id\"\n },\n {\n \"type\": \"BelongsToMany\",\n \"model\": \"Tag\",\n \"method\": \"tags\"\n },\n {\n \"type\": \"HasMany\",\n \"model\": \"Comment\",\n \"method\": \"comments\"\n }\n ],\n \"scopes\": [\n {\n \"name\": \"published\",\n \"column\": \"status\",\n \"value\": \"published\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\n\nclass Post extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'title',\n 'body',\n 'slug',\n 'status',\n 'user_id',\n ];\n\n public function scopePublished($query)\n {\n return $query->where('status', 'published');\n }\n\n public function author(): BelongsTo\n {\n return $this->belongsTo(User::class, 'user_id');\n }\n\n public function tags(): BelongsToMany\n {\n return $this->belongsToMany(Tag::class);\n }\n\n public function comments(): HasMany\n {\n return $this->hasMany(Comment::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"Tag\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Tag\",\n \"resource\": \"TagResource\",\n \"validation_mode\": \"inline\",\n \"eager_load\": [],\n \"paginate\": 20,\n \"store_rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:100\",\n \"unique:tags,name\"\n ],\n \"color\": [\n \"nullable\",\n \"string\",\n \"max:7\"\n ]\n },\n \"update_rules\": {\n \"name\": [\n \"sometimes\",\n \"string\",\n \"max:100\"\n ],\n \"color\": [\n \"nullable\",\n \"string\",\n \"max:7\"\n ]\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Resources\\TagResource;\nuse App\\Models\\Tag;\nuse Illuminate\\Http\\Request;\n\nclass TagController extends Controller\n{\n public function index(Request $request)\n {\n $tags = Tag::query()->paginate(20);\n\n return TagResource::collection($tags);\n }\n\n public function store(Request $request)\n {\n $data = $request->validate([\n 'name' => ['required', 'string', 'max:100', 'unique:tags,name'],\n 'color' => ['nullable', 'string', 'max:7'],\n ]);\n\n $tag = Tag::create($data);\n\n return response()->json(new TagResource($tag), 201);\n }\n\n public function show(Tag $tag)\n {\n return new TagResource($tag);\n }\n\n public function update(Request $request, Tag $tag)\n {\n $data = $request->validate([\n 'name' => ['sometimes', 'string', 'max:100'],\n 'color' => ['nullable', 'string', 'max:7'],\n ]);\n\n $tag->update($data);\n\n return new TagResource($tag);\n }\n\n public function destroy(Tag $tag)\n {\n $tag->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreCategoryRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\",\n \"unique:categories,name\"\n ],\n \"slug\": [\n \"required\",\n \"string\",\n \"max:255\",\n \"unique:categories,slug\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"parent_id\": [\n \"nullable\",\n \"integer\",\n \"exists:categories,id\"\n ]\n },\n \"unique_ignore_route_param\": \"category\"\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass StoreCategoryRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'name' => ['required', 'string', 'max:255', Rule::unique('categories', 'name')->ignore($this->route('category'))],\n 'slug' => ['required', 'string', 'max:255', Rule::unique('categories', 'slug')->ignore($this->route('category'))],\n 'description' => ['nullable', 'string'],\n 'parent_id' => ['nullable', 'integer', 'exists:categories,id'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"migration\",\n \"operation\": \"create\",\n \"table\": \"subscribers\",\n \"columns\": [\n {\n \"name\": \"email\",\n \"type\": \"string\",\n \"unique\": true\n },\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"status\",\n \"type\": \"string\",\n \"default\": \"active\"\n },\n {\n \"name\": \"subscribed_at\",\n \"type\": \"timestamp\",\n \"nullable\": true\n }\n ],\n \"timestamps\": true,\n \"soft_deletes\": false\n}"}, {"role": "assistant", "content": "<?php\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n public function up(): void\n {\n Schema::create('subscribers', function (Blueprint $table) {\n $table->id();\n $table->string('email')->unique();\n $table->string('name');\n $table->string('status')->default('active');\n $table->timestamp('subscribed_at')->nullable();\n $table->timestamps();\n });\n }\n\n public function down(): void\n {\n Schema::dropIfExists('subscribers');\n }\n};"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"pest_test\",\n \"class\": \"Post\",\n \"namespace\": \"Tests\\\\Feature\",\n \"model\": \"App\\\\Models\\\\Post\",\n \"endpoints\": [\n {\n \"method\": \"GET\",\n \"path\": \"/api/posts\",\n \"action\": \"index\"\n },\n {\n \"method\": \"POST\",\n \"path\": \"/api/posts\",\n \"action\": \"store\"\n },\n {\n \"method\": \"GET\",\n \"path\": \"/api/posts/{id}\",\n \"action\": \"show\"\n },\n {\n \"method\": \"PUT\",\n \"path\": \"/api/posts/{id}\",\n \"action\": \"update\"\n },\n {\n \"method\": \"DELETE\",\n \"path\": \"/api/posts/{id}\",\n \"action\": \"destroy\"\n }\n ],\n \"required_on_create\": [\n \"title\",\n \"body\"\n ],\n \"many_to_many\": {\n \"relation\": \"tags\",\n \"input_key\": \"tag_ids\"\n }\n}"}, {"role": "assistant", "content": "<?php\nuse App\\Models\\Post;\nuse App\\Models\\Tag;\n\ntest('GET /api/posts returns paginated list', function () {\n Post::factory()->count(3)->create();\n $this->getJson('/api/posts')\n ->assertOk()\n ->assertJsonCount(3, 'data');\n});\n\ntest('POST /api/posts creates a post with tags', function () {\n $tags = Tag::factory()->count(2)->create();\n $this->postJson('/api/posts', [\n 'title' => 'Test Post',\n 'body' => 'Post body',\n 'tag_ids' => $tags->pluck('id')->toArray(),\n ])->assertCreated()\n ->assertJsonPath('title', 'Test Post');\n});\n\ntest('POST /api/posts requires title and body', function () {\n $this->postJson('/api/posts', [])\n ->assertUnprocessable()\n ->assertJsonValidationErrors(['title', 'body']);\n});\n\ntest('PUT /api/posts/:id updates tags', function () {\n $post = Post::factory()->create();\n $tags = Tag::factory()->count(2)->create();\n $this->putJson(\"/api/posts/{$post->id}\", [\n 'title' => 'Updated Post',\n 'tag_ids' => $tags->pluck('id')->toArray(),\n ])->assertOk()\n ->assertJsonPath('title', 'Updated Post');\n});\n\ntest('DELETE /api/posts/:id deletes the post', function () {\n $post = Post::factory()->create();\n $this->deleteJson(\"/api/posts/{$post->id}\")\n ->assertNoContent();\n $this->assertDatabaseMissing('posts', ['id' => $post->id]);\n});"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreArticleRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"slug\": [\n \"required\",\n \"string\",\n \"max:255\",\n \"unique:articles,slug\"\n ],\n \"body\": [\n \"required\",\n \"string\"\n ],\n \"status\": [\n \"nullable\",\n \"string\",\n \"in:draft,published,archived\"\n ],\n \"category_id\": [\n \"required\",\n \"integer\",\n \"exists:categories,id\"\n ]\n },\n \"unique_ignore_route_param\": \"article\"\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass StoreArticleRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'title' => ['required', 'string', 'max:255'],\n 'slug' => ['required', 'string', 'max:255', Rule::unique('articles', 'slug')->ignore($this->route('article'))],\n 'body' => ['required', 'string'],\n 'status' => ['nullable', 'string', 'in:draft,published,archived'],\n 'category_id' => ['required', 'integer', 'exists:categories,id'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Product\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"products\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"name\",\n \"sku\",\n \"price\",\n \"stock\",\n \"category_id\"\n ],\n \"casts\": {\n \"price\": \"decimal:2\",\n \"stock\": \"integer\"\n },\n \"relationships\": [],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Product extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'name',\n 'sku',\n 'price',\n 'stock',\n 'category_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'price' => 'decimal:2',\n 'stock' => 'integer',\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"pest_test\",\n \"suite\": \"Feature\",\n \"class_under_test\": \"SubscriberController\",\n \"model\": \"Subscriber\",\n \"model_namespace\": \"App\\\\Models\",\n \"base_uri\": \"/api/subscribers\",\n \"test_cases\": [\n {\n \"name\": \"GET /api/subscribers returns paginated list\",\n \"method\": \"getJson\",\n \"uri\": \"/api/subscribers\",\n \"setup\": {\n \"factory_count\": 3\n },\n \"assertions\": [\n \"assertOk\",\n {\n \"assertJsonCount\": [\n 3,\n \"data\"\n ]\n }\n ]\n },\n {\n \"name\": \"POST /api/subscribers creates a subscriber\",\n \"method\": \"postJson\",\n \"uri\": \"/api/subscribers\",\n \"body\": {\n \"email\": \"test@example.com\",\n \"name\": \"Test User\",\n \"status\": \"active\"\n },\n \"assertions\": [\n \"assertCreated\",\n {\n \"assertJsonPath\": [\n \"email\",\n \"test@example.com\"\n ]\n }\n ]\n },\n {\n \"name\": \"POST /api/subscribers rejects duplicate email\",\n \"method\": \"postJson\",\n \"uri\": \"/api/subscribers\",\n \"setup\": {\n \"existing\": {\n \"email\": \"dupe@example.com\"\n }\n },\n \"body\": {\n \"email\": \"dupe@example.com\"\n },\n \"assertions\": [\n \"assertUnprocessable\",\n {\n \"assertJsonValidationErrors\": [\n [\n \"email\"\n ]\n ]\n }\n ]\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nuse App\\Models\\Subscriber;\nuse Illuminate\\Foundation\\Testing\\RefreshDatabase;\n\nuses(RefreshDatabase::class);\n\ntest('GET /api/subscribers returns paginated list', function () {\n Subscriber::factory()->count(3)->create();\n $this->getJson('/api/subscribers')\n ->assertOk()\n ->assertJsonCount(3, 'data');\n});\n\ntest('POST /api/subscribers creates a subscriber', function () {\n $this->postJson('/api/subscribers', [\n 'email' => 'test@example.com',\n 'name' => 'Test User',\n 'status' => 'active',\n ])->assertCreated()\n ->assertJsonPath('email', 'test@example.com');\n});\n\ntest('POST /api/subscribers rejects duplicate email', function () {\n Subscriber::factory()->create(['email' => 'dupe@example.com']);\n $this->postJson('/api/subscribers', ['email' => 'dupe@example.com'])\n ->assertUnprocessable()\n ->assertJsonValidationErrors(['email']);\n});"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Product\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"products\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"name\",\n \"sku\",\n \"price\",\n \"stock\",\n \"status\",\n \"category_id\"\n ],\n \"casts\": {\n \"price\": \"decimal:2\",\n \"stock\": \"integer\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"model\": \"Category\",\n \"method\": \"category\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\n\nclass Product extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'name',\n 'sku',\n 'price',\n 'stock',\n 'status',\n 'category_id',\n ];\n\n protected $casts = [\n 'price' => 'decimal:2',\n 'stock' => 'integer',\n ];\n\n public function category(): BelongsTo\n {\n return $this->belongsTo(Category::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Ticket\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"tickets\",\n \"has_factory\": true,\n \"soft_deletes\": true,\n \"fillable\": [\n \"subject\",\n \"body\",\n \"status\",\n \"user_id\",\n \"assigned_to\"\n ],\n \"casts\": {},\n \"relationships\": [],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass Ticket extends Model\n{\n use HasFactory, SoftDeletes;\n\n protected $fillable = [\n 'subject',\n 'body',\n 'status',\n 'user_id',\n 'assigned_to',\n ];\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"controller\",\n \"class\": \"Product\",\n \"namespace\": \"App\\\\Http\\\\Controllers\\\\Api\",\n \"model\": \"Product\",\n \"resource\": \"ProductResource\",\n \"form_request\": \"StoreProductRequest\",\n \"validation_mode\": \"form_request\",\n \"eager_load\": [\n \"category\"\n ],\n \"paginate\": 15,\n \"filters\": [\n \"status\",\n \"category_id\"\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Requests\\StoreProductRequest;\nuse App\\Http\\Resources\\ProductResource;\nuse App\\Models\\Product;\nuse Illuminate\\Http\\Request;\n\nclass ProductController extends Controller\n{\n public function index(Request $request)\n {\n $products = Product::query()\n ->when($request->filled('status'), fn ($q) => $q->where('status', $request->input('status')))\n ->when($request->filled('category_id'), fn ($q) => $q->where('category_id', $request->input('category_id')))\n ->with('category')\n ->paginate(15);\n\n return ProductResource::collection($products);\n }\n\n public function store(StoreProductRequest $request)\n {\n $product = Product::create($request->validated());\n\n return response()->json(new ProductResource($product->load('category')), 201);\n }\n\n public function show(Product $product)\n {\n return new ProductResource($product->load('category'));\n }\n\n public function update(StoreProductRequest $request, Product $product)\n {\n $product->update($request->validated());\n\n return new ProductResource($product->load('category'));\n }\n\n public function destroy(Product $product)\n {\n $product->delete();\n\n return response()->noContent();\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreMeetingRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"meeting_date\": [\n \"required\",\n \"date\"\n ],\n \"location\": [\n \"nullable\",\n \"string\",\n \"max:255\"\n ],\n \"room_id\": []\n },\n \"conditional_rules\": {\n \"room_id\": {\n \"POST\": [\n \"required\",\n \"integer\",\n \"exists:rooms,id\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"integer\",\n \"exists:rooms,id\"\n ]\n },\n \"meeting_date\": {\n \"POST\": [\n \"after:now\"\n ]\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreMeetingRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'title' => ['required', 'string', 'max:255'],\n 'meeting_date' => ['required', 'date', ...$this->isMethod('POST') ? ['after:now'] : []],\n 'location' => ['nullable', 'string', 'max:255'],\n 'room_id' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'integer', 'exists:rooms,id'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Review\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"reviews\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"rating\",\n \"body\",\n \"product_id\"\n ],\n \"casts\": {\n \"rating\": \"integer\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"method\": \"product\",\n \"related\": \"Product\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\n\nclass Review extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'rating',\n 'body',\n 'product_id',\n ];\n\n protected function casts(): array\n {\n return [\n 'rating' => 'integer',\n ];\n }\n\n public function product(): BelongsTo\n {\n return $this->belongsTo(Product::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Author\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"authors\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"name\",\n \"bio\",\n \"nationality\"\n ],\n \"casts\": {},\n \"relationships\": [\n {\n \"type\": \"HasMany\",\n \"method\": \"books\",\n \"related\": \"Book\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\n\nclass Author extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'name',\n 'bio',\n 'nationality',\n ];\n\n public function books(): HasMany\n {\n return $this->hasMany(Book::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"migration\",\n \"operation\": \"create\",\n \"table\": \"books\",\n \"columns\": [\n {\n \"name\": \"author_id\",\n \"type\": \"foreignId\",\n \"constrained\": \"authors\",\n \"on_delete\": \"cascade\"\n },\n {\n \"name\": \"title\",\n \"type\": \"string\"\n },\n {\n \"name\": \"isbn\",\n \"type\": \"string\",\n \"unique\": true,\n \"length\": 20\n },\n {\n \"name\": \"description\",\n \"type\": \"text\",\n \"nullable\": true\n },\n {\n \"name\": \"published_year\",\n \"type\": \"integer\",\n \"nullable\": true\n }\n ],\n \"timestamps\": true,\n \"soft_deletes\": true\n}"}, {"role": "assistant", "content": "<?php\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n public function up(): void\n {\n Schema::create('books', function (Blueprint $table) {\n $table->id();\n $table->foreignId('author_id')->constrained()->cascadeOnDelete();\n $table->string('title');\n $table->string('isbn', 20)->unique();\n $table->text('description')->nullable();\n $table->integer('published_year')->nullable();\n $table->softDeletes();\n $table->timestamps();\n });\n }\n\n public function down(): void\n {\n Schema::dropIfExists('books');\n }\n};"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"migration\",\n \"operation\": \"create\",\n \"table\": \"event_speaker\",\n \"pivot\": true,\n \"columns\": [\n {\n \"name\": \"event_id\",\n \"type\": \"foreignId\",\n \"constrained\": \"events\",\n \"on_delete\": \"cascade\"\n },\n {\n \"name\": \"speaker_id\",\n \"type\": \"foreignId\",\n \"constrained\": \"speakers\",\n \"on_delete\": \"cascade\"\n }\n ],\n \"timestamps\": false,\n \"soft_deletes\": false\n}"}, {"role": "assistant", "content": "<?php\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n public function up(): void\n {\n Schema::create('event_speaker', function (Blueprint $table) {\n $table->foreignId('event_id')->constrained()->cascadeOnDelete();\n $table->foreignId('speaker_id')->constrained()->cascadeOnDelete();\n $table->primary(['event_id', 'speaker_id']);\n });\n }\n\n public function down(): void\n {\n Schema::dropIfExists('event_speaker');\n }\n};"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"form_request\",\n \"class\": \"StoreProductRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"name\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"sku\": [\n \"required\",\n \"string\",\n \"max:50\",\n \"unique:products,sku\"\n ],\n \"price\": [\n \"required\",\n \"numeric\",\n \"min:0\"\n ],\n \"stock\": [\n \"nullable\",\n \"integer\",\n \"min:0\"\n ],\n \"category_id\": [\n \"required\",\n \"integer\",\n \"exists:categories,id\"\n ]\n },\n \"unique_ignore_route_param\": \"product\"\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Illuminate\\Validation\\Rule;\n\nclass StoreProductRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'name' => ['required', 'string', 'max:255'],\n 'sku' => ['required', 'string', 'max:50', Rule::unique('products', 'sku')->ignore($this->route('product'))],\n 'price' => ['required', 'numeric', 'min:0'],\n 'stock' => ['nullable', 'integer', 'min:0'],\n 'category_id' => ['required', 'integer', 'exists:categories,id'],\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"resource\",\n \"class\": \"PlaylistResource\",\n \"namespace\": \"App\\\\Http\\\\Resources\",\n \"fields\": [\n {\n \"key\": \"id\",\n \"source\": \"id\"\n },\n {\n \"key\": \"name\",\n \"source\": \"name\"\n },\n {\n \"key\": \"description\",\n \"source\": \"description\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"tracks_count\",\n \"modifier\": \"whenCounted\"\n },\n {\n \"key\": \"created_at\",\n \"source\": \"created_at\"\n }\n ],\n \"loaded_relations\": [\n {\n \"key\": \"tracks\",\n \"resource\": \"TrackResource\",\n \"type\": \"collection\"\n },\n {\n \"key\": \"owner\",\n \"resource\": \"UserResource\",\n \"type\": \"make\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\TrackResource;\nuse App\\Http\\Resources\\UserResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass PlaylistResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'name' => $this->name,\n 'description' => $this->whenNotNull($this->description),\n 'tracks_count' => $this->whenCounted('tracks'),\n 'tracks' => TrackResource::collection($this->whenLoaded('tracks')),\n 'owner' => UserResource::make($this->whenLoaded('owner')),\n 'created_at' => $this->created_at,\n ];\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"Setting\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"settings\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"key\",\n \"value\",\n \"group\"\n ],\n \"casts\": {},\n \"relationships\": [],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Setting extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'key',\n 'value',\n 'group',\n ];\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"model\",\n \"class\": \"OrderItem\",\n \"namespace\": \"App\\\\Models\",\n \"table\": \"order_items\",\n \"has_factory\": true,\n \"soft_deletes\": false,\n \"fillable\": [\n \"order_id\",\n \"product_id\",\n \"qty\",\n \"price\"\n ],\n \"casts\": {\n \"qty\": \"integer\",\n \"price\": \"decimal:2\"\n },\n \"relationships\": [\n {\n \"type\": \"BelongsTo\",\n \"method\": \"order\",\n \"related\": \"Order\"\n }\n ],\n \"scopes\": []\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\n\nclass OrderItem extends Model\n{\n use HasFactory;\n\n protected $fillable = [\n 'order_id',\n 'product_id',\n 'qty',\n 'price',\n ];\n\n protected function casts(): array\n {\n return [\n 'qty' => 'integer',\n 'price' => 'decimal:2',\n ];\n }\n\n public function order(): BelongsTo\n {\n return $this->belongsTo(Order::class);\n }\n}"}]}
{"messages": [{"role": "system", "content": "You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.\n\nRules:\n- Output ONLY the PHP file. No markdown fences. No explanation. No extra comments.\n- Implement EXACTLY what the spec says. Do not add fields, relationships, or methods not in the spec.\n- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[]. Import every relationship return type (BelongsTo etc).\n- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201). If validation_mode=inline use $request->validate([...]) in store() and update(). If validation_mode=form_request import and use the FormRequest class.\n- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a \"resource\" key, add `use App\\Http\\Resources\\{ResourceClass};` at the top \u2014 even if it is in the same namespace. Never use a Resource class without importing it.\n- artifact=form_request: rules() returns exact rules from spec. If conditional_rules present, expand each field using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true. When unique_ignore_route_param is set (non-null), replace any 'unique:table,col' string rule with Rule::unique('table', 'col')->ignore($this->route('param')). Import use Illuminate\\Validation\\Rule; at the top.\n- artifact=controller: When the model has FK fields in fillable (e.g. author_id, category_id), ALWAYS include them in $request->validated() passed to Model::create(). NEVER exclude FK fields or set them separately after create()."}, {"role": "user", "content": "{\n \"laravel_version\": \"13.x\",\n \"artifact\": \"pest_test\",\n \"class\": \"Article\",\n \"namespace\": \"Tests\\\\Feature\",\n \"model\": \"App\\\\Models\\\\Article\",\n \"endpoints\": [\n {\n \"method\": \"GET\",\n \"path\": \"/api/articles\",\n \"action\": \"index\"\n },\n {\n \"method\": \"POST\",\n \"path\": \"/api/articles\",\n \"action\": \"store\"\n },\n {\n \"method\": \"GET\",\n \"path\": \"/api/articles/{id}\",\n \"action\": \"show\"\n },\n {\n \"method\": \"PUT\",\n \"path\": \"/api/articles/{id}\",\n \"action\": \"update\"\n },\n {\n \"method\": \"DELETE\",\n \"path\": \"/api/articles/{id}\",\n \"action\": \"destroy\"\n }\n ],\n \"soft_deletes\": true,\n \"required_on_create\": [\n \"title\",\n \"body\"\n ]\n}"}, {"role": "assistant", "content": "<?php\nuse App\\Models\\Article;\n\ntest('GET /api/articles returns paginated list', function () {\n Article::factory()->count(3)->create();\n $this->getJson('/api/articles')\n ->assertOk()\n ->assertJsonCount(3, 'data');\n});\n\ntest('POST /api/articles creates an article', function () {\n $this->postJson('/api/articles', [\n 'title' => 'Test Article',\n 'body' => 'Article body content',\n ])->assertCreated()\n ->assertJsonPath('title', 'Test Article');\n});\n\ntest('POST /api/articles requires title and body', function () {\n $this->postJson('/api/articles', [])\n ->assertUnprocessable()\n ->assertJsonValidationErrors(['title', 'body']);\n});\n\ntest('GET /api/articles/:id shows article', function () {\n $article = Article::factory()->create();\n $this->getJson(\"/api/articles/{$article->id}\")\n ->assertOk()\n ->assertJsonPath('id', $article->id);\n});\n\ntest('DELETE /api/articles/:id soft deletes the article', function () {\n $article = Article::factory()->create();\n $this->deleteJson(\"/api/articles/{$article->id}\")\n ->assertNoContent();\n $this->assertSoftDeleted('articles', ['id' => $article->id]);\n});"}]}