fchis's picture
Upload valid.jsonl with huggingface_hub
a6119bd verified
{"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\": \"Event\",\n \"namespace\": \"Tests\\\\Feature\",\n \"model\": \"App\\\\Models\\\\Event\",\n \"endpoints\": [\n {\n \"method\": \"GET\",\n \"path\": \"/api/events\",\n \"action\": \"index\"\n },\n {\n \"method\": \"POST\",\n \"path\": \"/api/events\",\n \"action\": \"store\"\n },\n {\n \"method\": \"GET\",\n \"path\": \"/api/events/{id}\",\n \"action\": \"show\"\n },\n {\n \"method\": \"PUT\",\n \"path\": \"/api/events/{id}\",\n \"action\": \"update\"\n },\n {\n \"method\": \"DELETE\",\n \"path\": \"/api/events/{id}\",\n \"action\": \"destroy\"\n }\n ],\n \"required_on_create\": [\n \"title\",\n \"event_date\",\n \"venue_id\"\n ],\n \"optional_on_update\": [\n \"venue_id\"\n ]\n}"}, {"role": "assistant", "content": "<?php\nuse App\\Models\\Event;\nuse App\\Models\\Venue;\nuse App\\Models\\Speaker;\n\ntest('GET /api/events returns paginated list', function () {\n Event::factory()->count(3)->create();\n $this->getJson('/api/events')\n ->assertOk()\n ->assertJsonCount(3, 'data');\n});\n\ntest('POST /api/events creates an event', function () {\n $venue = Venue::factory()->create();\n $this->postJson('/api/events', [\n 'title' => 'Test Event',\n 'event_date' => now()->addDays(10)->toDateString(),\n 'venue_id' => $venue->id,\n ])->assertCreated()\n ->assertJsonPath('title', 'Test Event');\n});\n\ntest('POST /api/events requires venue_id', function () {\n $this->postJson('/api/events', [\n 'title' => 'Test Event',\n 'event_date' => now()->addDays(10)->toDateString(),\n ])->assertUnprocessable()\n ->assertJsonValidationErrors(['venue_id']);\n});\n\ntest('PUT /api/events/:id venue_id is optional', function () {\n $event = Event::factory()->create();\n $this->putJson(\"/api/events/{$event->id}\", [\n 'title' => 'Updated Event',\n ])->assertOk()\n ->assertJsonPath('title', 'Updated Event');\n});\n\ntest('DELETE /api/events/:id deletes the event', function () {\n $event = Event::factory()->create();\n $this->deleteJson(\"/api/events/{$event->id}\")\n ->assertNoContent();\n $this->assertDatabaseMissing('events', ['id' => $event->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\": \"resource\",\n \"class\": \"BookResource\",\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\": \"isbn\",\n \"source\": \"isbn\"\n },\n {\n \"key\": \"description\",\n \"source\": \"description\",\n \"modifier\": \"whenNotNull\"\n },\n {\n \"key\": \"published_year\",\n \"source\": \"published_year\",\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 {\n \"key\": \"author\",\n \"resource\": \"AuthorResource\",\n \"type\": \"make\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\AuthorResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass BookResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'title' => $this->title,\n 'isbn' => $this->isbn,\n 'description' => $this->whenNotNull($this->description),\n 'published_year' => $this->whenNotNull($this->published_year),\n 'author' => AuthorResource::make($this->whenLoaded('author')),\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\": \"PostResource\",\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\": \"body\",\n \"source\": \"body\"\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\": \"author\",\n \"resource\": \"AuthorResource\",\n \"type\": \"make\"\n },\n {\n \"key\": \"tags\",\n \"resource\": \"TagResource\",\n \"type\": \"collection\"\n }\n ]\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Resources;\n\nuse App\\Http\\Resources\\AuthorResource;\nuse App\\Http\\Resources\\TagResource;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass PostResource extends JsonResource\n{\n public function toArray(Request $request): array\n {\n return [\n 'id' => $this->id,\n 'title' => $this->title,\n 'body' => $this->body,\n 'status' => $this->status,\n 'author' => AuthorResource::make($this->whenLoaded('author')),\n 'tags' => TagResource::collection($this->whenLoaded('tags')),\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\": \"Order\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"rules\": {\n \"customer_id\": [],\n \"status\": [\n \"required\",\n \"string\",\n \"in:pending,processing,shipped,delivered,cancelled\"\n ],\n \"shipping_address\": [],\n \"notes\": [\n \"nullable\",\n \"string\"\n ],\n \"items\": [],\n \"items.*.product_id\": [\n \"integer\",\n \"exists:products,id\"\n ],\n \"items.*.quantity\": [\n \"integer\",\n \"min:1\"\n ]\n },\n \"conditional_rules\": {\n \"customer_id\": {\n \"POST\": [\n \"required\",\n \"integer\",\n \"exists:customers,id\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"integer\",\n \"exists:customers,id\"\n ]\n },\n \"shipping_address\": {\n \"POST\": [\n \"required\",\n \"string\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"string\"\n ]\n },\n \"items\": {\n \"POST\": [\n \"required\",\n \"array\",\n \"min:1\"\n ],\n \"PUT\": [\n \"sometimes\",\n \"array\"\n ]\n }\n }\n}"}, {"role": "assistant", "content": "<?php\nnamespace App\\Http\\Requests;\n\nuse Illuminate\\Foundation\\Http\\FormRequest;\n\nclass StoreOrderRequest extends FormRequest\n{\n public function authorize(): bool\n {\n return true;\n }\n\n public function rules(): array\n {\n return [\n 'customer_id' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'integer', 'exists:customers,id'],\n 'status' => ['required', 'string', 'in:pending,processing,shipped,delivered,cancelled'],\n 'shipping_address' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'string'],\n 'notes' => ['nullable', 'string'],\n 'items' => [$this->isMethod('POST') ? 'required' : 'sometimes', 'array', ...$this->isMethod('POST') ? ['min:1'] : []],\n 'items.*.product_id' => ['integer', 'exists:products,id'],\n 'items.*.quantity' => ['integer', 'min:1'],\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\": \"StoreEventRequest\",\n \"namespace\": \"App\\\\Http\\\\Requests\",\n \"authorize\": true,\n \"rules\": {\n \"title\": [\n \"required\",\n \"string\",\n \"max:255\"\n ],\n \"description\": [\n \"nullable\",\n \"string\"\n ],\n \"venue_id\": [\n \"required_on_post\",\n \"integer\",\n \"exists:venues,id\"\n ],\n \"event_date\": [\n \"required\",\n \"date\",\n \"after_now_on_post\"\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 \"unique_ignore_route_param\": null\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' : 'sometimes'],\n 'status' => ['nullable', 'string', 'in:draft,published,cancelled'],\n 'speaker_ids' => ['nullable', 'array'],\n 'speaker_ids.*' => ['integer', 'exists:speakers,id'],\n ];\n }\n}"}]}