[{"data":1,"prerenderedAt":858},["ShallowReactive",2],{"libs":3,"navigation-laravel-api-revisions":115,"\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Fsources-and-conditions":299,"\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Fsources-and-conditions-surround":853},[4,45,69,95],{"id":5,"color":6,"compatibility":7,"extension":20,"icon":21,"links":22,"meta":27,"name":28,"order":29,"package":30,"related":31,"stem":34,"tagline":35,"__hash__":36,"slug":37,"repository":38,"branch":39,"path":40,"collection":41,"entry":42,"home":43,"version":44},"laravel_json_api_meta\u002Fdocs\u002Fsite\u002Flib.yml","violet",[8,13,16],{"version":9,"php":10,"laravel":11,"status":12},"3.x","^8.3","^12.46 || ^13.0","active",{"version":14,"php":10,"laravel":11,"status":15},"2.x","eol",{"version":17,"php":18,"laravel":19,"status":15},"1.x","^8.1","^10.0 || ^11.0 || ^12.0 || ^13.0","yml","i-lucide-braces",[23],{"label":24,"to":25,"icon":26},"JSON:API 1.1","https:\u002F\u002Fjsonapi.org\u002Fformat\u002F","i-lucide-book-marked",{},"Laravel JSON:API",10,"ark4ne\u002Flaravel-json-api",[32,33],"laravel-api-revisions","laravel-openapi-generator","docs\u002Fsite\u002Flib","JSON:API 1.1 resources for Laravel, with typed values, validated includes and fieldsets, and API revisions.","ILGoVp9rzKYDQc18VV8kkXy3EQOQ8rv87JblFKXYDrU","laravel-json-api","Ark4ne\u002Flaravel-json-api","master","docs\u002Fsite","laravel_json_api","\u002Flaravel-json-api\u002Fgetting-started\u002Fintroduction","\u002Flaravel-json-api","v3.0.0",{"id":46,"color":47,"compatibility":48,"extension":20,"icon":50,"links":51,"meta":56,"name":57,"order":58,"package":59,"related":60,"stem":34,"tagline":61,"__hash__":62,"slug":32,"repository":63,"branch":64,"path":40,"collection":65,"entry":66,"home":67,"version":68},"laravel_api_revisions_meta\u002Fdocs\u002Fsite\u002Flib.yml","amber",[49],{"version":17,"php":10,"laravel":11,"status":12},"i-lucide-git-branch",[52],{"label":53,"to":54,"icon":55},"Agent skill","https:\u002F\u002Fgithub.com\u002FArk4ne\u002Flaravel-api-revisions\u002Ftree\u002Fmain\u002Fskills\u002Flaravel-api-revisions","i-lucide-bot",{},"Laravel API Revisions",20,"ark4ne\u002Flaravel-api-revisions",[37,33],"Typed schemas for Laravel resources and form requests, evolved through dated API revisions, Stripe-style.","w24MBVK4_XliIZ8nVcfnuT9OgR-m-Ytxz31Pxua_mLM","Ark4ne\u002Flaravel-api-revisions","main","laravel_api_revisions","\u002Flaravel-api-revisions\u002Fgetting-started\u002Fintroduction","\u002Flaravel-api-revisions","v1.0.0",{"id":70,"color":71,"compatibility":72,"extension":20,"icon":77,"links":78,"meta":82,"name":83,"order":84,"package":85,"related":86,"stem":34,"tagline":88,"__hash__":89,"slug":33,"repository":90,"branch":39,"path":40,"collection":91,"entry":92,"home":93,"version":94},"laravel_openapi_generator_meta\u002Fdocs\u002Fsite\u002Flib.yml","emerald",[73,75],{"version":17,"php":10,"laravel":74,"status":12},"^13.0",{"version":76,"php":18,"laravel":19,"status":15},"0.6","i-lucide-file-json",[79],{"label":80,"to":81,"icon":26},"OpenAPI Specification","https:\u002F\u002Fspec.openapis.org\u002Foas\u002Flatest.html",{},"Laravel OpenAPI Generator",30,"ark4ne\u002Flaravel-openapi-generator",[87,37,32],"openapi-writer","Generates OpenAPI 3.0, 3.1 and 3.2 documents from a Laravel application, its routes, form requests and resources.","DTt0SVqegMImLmWmwL8LCW5lxRCWFYcnBFOaquLpVwc","Ark4ne\u002Flaravel-openapi-generator","laravel_openapi_generator","\u002Flaravel-openapi-generator\u002Fgetting-started\u002Fintroduction","\u002Flaravel-openapi-generator","v1.2.0",{"id":96,"color":97,"compatibility":98,"extension":20,"icon":101,"links":102,"meta":104,"name":105,"order":106,"package":107,"related":108,"stem":34,"tagline":109,"__hash__":110,"slug":87,"repository":111,"branch":64,"path":40,"collection":112,"entry":113,"home":114,"version":68},"openapi_writer_meta\u002Fdocs\u002Fsite\u002Flib.yml","sky",[99],{"version":17,"php":100,"status":12},"^8.2","i-lucide-file-pen-line",[103],{"label":80,"to":81,"icon":26},{},"OpenAPI Writer",40,"ark4ne\u002Fopenapi-writer",[33],"Framework-agnostic, fluent and immutable PHP builder for OpenAPI 3.0, 3.1 and 3.2 documents, written as JSON or YAML and validated.","JFQcdQ9GEChOkfRKibLjoxZOfnt6HYNsayX2melOzMk","Ark4ne\u002Fopenapi-writer","openapi_writer","\u002Fopenapi-writer\u002Fgetting-started\u002Fintroduction","\u002Fopenapi-writer",[116,135,153,175,205,235,257,287],{"title":117,"since":118,"experimental":119,"icon":120,"path":121,"stem":122,"children":123,"page":119},"Getting started",null,false,"i-lucide-rocket","\u002Flaravel-api-revisions\u002Fgetting-started","laravel-api-revisions\u002F1.getting-started",[124,127,131],{"title":125,"path":66,"stem":126,"since":118,"experimental":119},"Introduction","laravel-api-revisions\u002F1.getting-started\u002F1.introduction",{"title":128,"path":129,"stem":130,"since":118,"experimental":119},"Installation","\u002Flaravel-api-revisions\u002Fgetting-started\u002Finstallation","laravel-api-revisions\u002F1.getting-started\u002F2.installation",{"title":132,"path":133,"stem":134,"since":118,"experimental":119},"Quick start","\u002Flaravel-api-revisions\u002Fgetting-started\u002Fquick-start","laravel-api-revisions\u002F1.getting-started\u002F3.quick-start",{"title":136,"since":118,"experimental":119,"icon":137,"path":138,"stem":139,"children":140,"page":119},"Revisions","i-lucide-calendar-clock","\u002Flaravel-api-revisions\u002Frevisions","laravel-api-revisions\u002F2.revisions",[141,145,149],{"title":142,"path":143,"stem":144,"since":118,"experimental":119},"The revision enum","\u002Flaravel-api-revisions\u002Frevisions\u002Fthe-revision-enum","laravel-api-revisions\u002F2.revisions\u002F1.the-revision-enum",{"title":146,"path":147,"stem":148,"since":118,"experimental":119},"Resolving the revision","\u002Flaravel-api-revisions\u002Frevisions\u002Fresolving-the-revision","laravel-api-revisions\u002F2.revisions\u002F2.resolving-the-revision",{"title":150,"path":151,"stem":152,"since":118,"experimental":119},"Outside HTTP","\u002Flaravel-api-revisions\u002Frevisions\u002Foutside-http","laravel-api-revisions\u002F2.revisions\u002F3.outside-http",{"title":154,"since":118,"experimental":119,"icon":155,"path":156,"stem":157,"children":158,"page":119},"Declaring the head","i-lucide-file-code","\u002Flaravel-api-revisions\u002Fdeclaring-the-head","laravel-api-revisions\u002F3.declaring-the-head",[159,163,167,171],{"title":160,"path":161,"stem":162,"since":118,"experimental":119},"Schema vocabulary","\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Fschema-vocabulary","laravel-api-revisions\u002F3.declaring-the-head\u002F1.schema-vocabulary",{"title":164,"path":165,"stem":166,"since":118,"experimental":119},"Sources and conditions","\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Fsources-and-conditions","laravel-api-revisions\u002F3.declaring-the-head\u002F2.sources-and-conditions",{"title":168,"path":169,"stem":170,"since":118,"experimental":119},"Responses","\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Fresponses","laravel-api-revisions\u002F3.declaring-the-head\u002F3.responses",{"title":172,"path":173,"stem":174,"since":118,"experimental":119},"Requests","\u002Flaravel-api-revisions\u002Fdeclaring-the-head\u002Frequests","laravel-api-revisions\u002F3.declaring-the-head\u002F4.requests",{"title":176,"since":118,"experimental":119,"icon":177,"path":178,"stem":179,"children":180,"page":119},"Evolving the API","i-lucide-history","\u002Flaravel-api-revisions\u002Fevolving-the-api","laravel-api-revisions\u002F4.evolving-the-api",[181,185,189,193,197,201],{"title":182,"path":183,"stem":184,"since":118,"experimental":119},"Adding a revision","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Fadding-a-revision","laravel-api-revisions\u002F4.evolving-the-api\u002F1.adding-a-revision",{"title":186,"path":187,"stem":188,"since":118,"experimental":119},"Adding and removing fields","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Fadding-and-removing","laravel-api-revisions\u002F4.evolving-the-api\u002F2.adding-and-removing",{"title":190,"path":191,"stem":192,"since":118,"experimental":119},"Renaming and retyping","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Frenaming-and-retyping","laravel-api-revisions\u002F4.evolving-the-api\u002F3.renaming-and-retyping",{"title":194,"path":195,"stem":196,"since":118,"experimental":119},"Conversions","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Fconversions","laravel-api-revisions\u002F4.evolving-the-api\u002F4.conversions",{"title":198,"path":199,"stem":200,"since":118,"experimental":119},"Class lifetime","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Fclass-lifetime","laravel-api-revisions\u002F4.evolving-the-api\u002F5.class-lifetime",{"title":202,"path":203,"stem":204,"since":118,"experimental":119},"Retiring a revision","\u002Flaravel-api-revisions\u002Fevolving-the-api\u002Fretiring-a-revision","laravel-api-revisions\u002F4.evolving-the-api\u002F6.retiring-a-revision",{"title":206,"since":118,"experimental":119,"icon":207,"path":208,"stem":209,"children":210,"page":119},"Tooling","i-lucide-wrench","\u002Flaravel-api-revisions\u002Ftooling","laravel-api-revisions\u002F5.tooling",[211,215,219,223,227,231],{"title":212,"path":213,"stem":214,"since":118,"experimental":119},"Check","\u002Flaravel-api-revisions\u002Ftooling\u002Fcheck","laravel-api-revisions\u002F5.tooling\u002F1.check",{"title":216,"path":217,"stem":218,"since":118,"experimental":119},"Lock","\u002Flaravel-api-revisions\u002Ftooling\u002Flock","laravel-api-revisions\u002F5.tooling\u002F2.lock",{"title":220,"path":221,"stem":222,"since":118,"experimental":119},"Export and changelog","\u002Flaravel-api-revisions\u002Ftooling\u002Fexport-and-changelog","laravel-api-revisions\u002F5.tooling\u002F3.export-and-changelog",{"title":224,"path":225,"stem":226,"since":118,"experimental":119},"Testing","\u002Flaravel-api-revisions\u002Ftooling\u002Ftesting","laravel-api-revisions\u002F5.tooling\u002F4.testing",{"title":228,"path":229,"stem":230,"since":118,"experimental":119},"Static analysis","\u002Flaravel-api-revisions\u002Ftooling\u002Fstatic-analysis","laravel-api-revisions\u002F5.tooling\u002F5.static-analysis",{"title":232,"path":233,"stem":234,"since":118,"experimental":119},"Performance and Octane","\u002Flaravel-api-revisions\u002Ftooling\u002Fperformance-and-octane","laravel-api-revisions\u002F5.tooling\u002F6.performance-and-octane",{"title":236,"since":118,"experimental":119,"icon":237,"path":238,"stem":239,"children":240,"page":119},"Extending","i-lucide-puzzle","\u002Flaravel-api-revisions\u002Fextending","laravel-api-revisions\u002F6.extending",[241,245,249,253],{"title":242,"path":243,"stem":244,"since":118,"experimental":119},"Custom types","\u002Flaravel-api-revisions\u002Fextending\u002Fcustom-types","laravel-api-revisions\u002F6.extending\u002F1.custom-types",{"title":246,"path":247,"stem":248,"since":118,"experimental":119},"Descriptor macros","\u002Flaravel-api-revisions\u002Fextending\u002Fdescriptor-macros","laravel-api-revisions\u002F6.extending\u002F2.descriptor-macros",{"title":250,"path":251,"stem":252,"since":118,"experimental":119},"Custom checks","\u002Flaravel-api-revisions\u002Fextending\u002Fcustom-checks","laravel-api-revisions\u002F6.extending\u002F3.custom-checks",{"title":254,"path":255,"stem":256,"since":118,"experimental":119},"Without Laravel","\u002Flaravel-api-revisions\u002Fextending\u002Fwithout-laravel","laravel-api-revisions\u002F6.extending\u002F4.without-laravel",{"title":258,"since":118,"experimental":119,"icon":259,"path":260,"stem":261,"children":262,"page":119},"Reference","i-lucide-book-open","\u002Flaravel-api-revisions\u002Freference","laravel-api-revisions\u002F7.reference",[263,267,271,275,279,283],{"title":264,"path":265,"stem":266,"since":118,"experimental":119},"Configuration","\u002Flaravel-api-revisions\u002Freference\u002Fconfiguration","laravel-api-revisions\u002F7.reference\u002F1.configuration",{"title":268,"path":269,"stem":270,"since":118,"experimental":119},"Schema helpers","\u002Flaravel-api-revisions\u002Freference\u002Fschema-helpers","laravel-api-revisions\u002F7.reference\u002F2.schema-helpers",{"title":272,"path":273,"stem":274,"since":118,"experimental":119},"Revision methods","\u002Flaravel-api-revisions\u002Freference\u002Frevision-methods","laravel-api-revisions\u002F7.reference\u002F3.revision-methods",{"title":276,"path":277,"stem":278,"since":118,"experimental":119},"Commands","\u002Flaravel-api-revisions\u002Freference\u002Fcommands","laravel-api-revisions\u002F7.reference\u002F4.commands",{"title":280,"path":281,"stem":282,"since":118,"experimental":119},"Check diagnostics","\u002Flaravel-api-revisions\u002Freference\u002Fcheck-diagnostics","laravel-api-revisions\u002F7.reference\u002F5.check-diagnostics",{"title":284,"path":285,"stem":286,"since":118,"experimental":119},"Exceptions","\u002Flaravel-api-revisions\u002Freference\u002Fexceptions","laravel-api-revisions\u002F7.reference\u002F6.exceptions",{"title":288,"path":289,"children":290},"Releases","\u002Flaravel-api-revisions\u002Freleases",[291,295],{"title":292,"path":293,"stem":294,"since":118,"experimental":119},"Upgrade guide","\u002Flaravel-api-revisions\u002Fupgrade","laravel-api-revisions\u002FUPGRADE",{"title":296,"path":297,"stem":298,"since":118,"experimental":119},"Changelog","\u002Flaravel-api-revisions\u002Fchangelog","laravel-api-revisions\u002FCHANGELOG",{"id":300,"title":164,"body":301,"description":846,"experimental":119,"extension":847,"links":118,"meta":848,"navigation":849,"path":165,"rawbody":850,"seo":851,"since":118,"stem":166,"__hash__":852},"laravel_api_revisions\u002Flaravel-api-revisions\u002F3.declaring-the-head\u002F2.sources-and-conditions.md",{"type":302,"value":303,"toc":840},"minimark",[304,317,322,330,401,405,408,473,490,500,522,526,540,599,623,756,759,778,782,833,836],[305,306,307,308,312,313,316],"p",{},"A descriptor never holds a value. It says where to read one: its ",[309,310,311],"strong",{},"source",", read on a ",[309,314,315],{},"subject",".",[318,319,321],"h2",{"id":320},"the-subject","The subject",[305,323,324,325,329],{},"The subject is what a declaration reads: the model of a ",[326,327,328],"code",{},"JsonResource",", each item of a list, the value of an object's\nsource.",[331,332,333,346],"table",{},[334,335,336],"thead",{},[337,338,339,343],"tr",{},[340,341,342],"th",{},"Declaration",[340,344,345],{},"Subject of its children",[347,348,349,365,378,388],"tbody",{},[337,350,351,358],{},[352,353,354,355],"td",{},"a resource's ",[326,356,357],{},"toArray()",[352,359,360,361,364],{},"the resource's model (",[326,362,363],{},"$this->resource",")",[337,366,367,372],{},[352,368,369],{},[326,370,371],{},"Schema::object([...], 'shippingAddress')",[352,373,374,375],{},"the value of ",[326,376,377],{},"shippingAddress",[337,379,380,385],{},[352,381,382],{},[326,383,384],{},"Schema::object([...])",[352,386,387],{},"the parent's subject",[337,389,390,395],{},[352,391,392],{},[326,393,394],{},"Schema::list(Schema::object([...]), 'lines')",[352,396,397,398],{},"each item of ",[326,399,400],{},"lines",[318,402,404],{"id":403},"the-source","The source",[305,406,407],{},"The source is always the last argument of a helper:",[331,409,410,419],{},[334,411,412],{},[337,413,414,416],{},[340,415,342],{},[340,417,418],{},"Reads",[347,420,421,434,447,463],{},[337,422,423,428],{},[352,424,425],{},[326,426,427],{},"'title' => Schema::string()",[352,429,430,433],{},[326,431,432],{},"title",", the key the field is declared under (its head key, at every revision)",[337,435,436,441],{},[352,437,438],{},[326,439,440],{},"Schema::int('total_cents')",[352,442,443,444],{},"the key ",[326,445,446],{},"total_cents",[337,448,449,454],{},[352,450,451],{},[326,452,453],{},"Schema::string('customer.name')",[352,455,456,457,460,461],{},"a dotted path; ",[326,458,459],{},"null"," as soon as a segment is ",[326,462,459],{},[337,464,465,470],{},[352,466,467],{},[326,468,469],{},"Schema::string(fn ($value, Order $order) => $order->fullName())",[352,471,472],{},"the closure",[305,474,475,476,479,480,483,484,486,487,489],{},"A source closure receives ",[326,477,478],{},"($value, $subject)"," and may declare fewer parameters. ",[326,481,482],{},"$value"," is the value of the declared\nkey when the subject holds it without side effect (an existing offset, an initialized property, a loaded attribute or\nrelation), ",[326,485,459],{}," otherwise: computing ",[326,488,482],{}," never triggers a lazy load or an accessor.",[305,491,492,493,496,497,316],{},"A key or a path is read as ",[326,494,495],{},"$model->key"," would be: casts and accessors apply, and an unloaded relation is\nlazy-loaded. Guard a relation with ",[326,498,499],{},"whenLoaded()",[501,502,503],"warning",{},[305,504,505,508,509,512,513,517,518,521],{},[309,506,507],{},"A source is never an evaluated value."," The shapes are compiled once, without a real subject, and no source runs then.\nA string is always read as a key: ",[326,510,511],{},"Schema::string($this->title)"," reads the key ",[514,515,516],"em",{},"named by the title",". Write\n",[326,519,520],{},"Schema::string('title')"," or a closure. Any other value (an int, a model) throws.",[318,523,525],{"id":524},"conditions","Conditions",[305,527,528,529,532,533,535,536,539],{},"A condition decides whether a field is rendered at all. A field refused by a condition is ",[309,530,531],{},"omitted"," (never ",[326,534,459],{},")\nand ",[309,537,538],{},"never read",", so a condition can guard an expensive source.",[331,541,542,552],{},[334,543,544],{},[337,545,546,549],{},[340,547,548],{},"Modifier",[340,550,551],{},"Keeps the field when",[347,553,554,564,574,587],{},[337,555,556,561],{},[352,557,558],{},[326,559,560],{},"whenHas(?string $key = null)",[352,562,563],{},"the subject has the key (the declared key by default)",[337,565,566,571],{},[352,567,568],{},[326,569,570],{},"whenLoaded('customer')",[352,572,573],{},"the relation is loaded",[337,575,576,581],{},[352,577,578],{},[326,579,580],{},"when(fn ($subject, $attribute) => ...)",[352,582,583,584],{},"the closure returns ",[326,585,586],{},"true",[337,588,589,594],{},[352,590,591],{},[326,592,593],{},"unless(fn ($subject, $attribute) => ...)",[352,595,583,596],{},[326,597,598],{},"false",[305,600,601,604,605,607,608,611,612,615,616,619,620,622],{},[326,602,603],{},"whenHas()"," and ",[326,606,499],{}," run first, then ",[326,609,610],{},"when()"," \u002F ",[326,613,614],{},"unless()",", then the source. A condition closure receives\nthe subject and the key read (",[326,617,618],{},"'customer.name'"," for ",[326,621,453],{},", else the declared key):",[624,625,630],"pre",{"className":626,"code":627,"language":628,"meta":629,"style":629},"language-php shiki shiki-themes material-theme-lighter github-light github-dark","'invoice_url' => Schema::string(\n    fn ($value, Order $order) => $order->invoiceUrl(),\n)\n    ->when(fn (Order $order) => $order->isPaid()),\n","php","",[326,631,632,666,709,715],{"__ignoreMap":629},[633,634,637,641,645,647,651,655,658,662],"span",{"class":635,"line":636},"line",1,[633,638,640],{"class":639},"sjJ54","'",[633,642,644],{"class":643},"s_sjI","invoice_url",[633,646,640],{"class":639},[633,648,650],{"class":649},"smGrS"," =>",[633,652,654],{"class":653},"sZMiF"," Schema",[633,656,657],{"class":649},"::",[633,659,661],{"class":660},"sGLFI","string",[633,663,665],{"class":664},"sP7_E","(\n",[633,667,669,673,676,680,683,686,689,692,694,696,698,700,703,706],{"class":635,"line":668},2,[633,670,672],{"class":671},"sbsja","    fn",[633,674,675],{"class":664}," ($",[633,677,679],{"class":678},"su5hD","value",[633,681,682],{"class":664},",",[633,684,685],{"class":653}," Order",[633,687,688],{"class":664}," $",[633,690,691],{"class":678},"order",[633,693,364],{"class":664},[633,695,650],{"class":664},[633,697,688],{"class":664},[633,699,691],{"class":678},[633,701,702],{"class":649},"->",[633,704,705],{"class":660},"invoiceUrl",[633,707,708],{"class":664},"(),\n",[633,710,712],{"class":635,"line":711},3,[633,713,714],{"class":664},")\n",[633,716,718,721,724,727,730,733,736,738,740,742,744,746,748,750,753],{"class":635,"line":717},4,[633,719,720],{"class":649},"    ->",[633,722,723],{"class":660},"when",[633,725,726],{"class":664},"(",[633,728,729],{"class":671},"fn",[633,731,732],{"class":664}," (",[633,734,735],{"class":653},"Order",[633,737,688],{"class":664},[633,739,691],{"class":678},[633,741,364],{"class":664},[633,743,650],{"class":664},[633,745,688],{"class":664},[633,747,691],{"class":678},[633,749,702],{"class":649},[633,751,752],{"class":660},"isPaid",[633,754,755],{"class":664},"()),\n",[305,757,758],{},"A conditional field is optional in the export.",[305,760,761,762,765,766,769,770,773,774,777],{},"Put conditions on the descriptor rather than using Laravel's native ",[326,763,764],{},"$this->when()",", ",[326,767,768],{},"mergeWhen()"," or\n",[326,771,772],{},"$this->whenLoaded()",": those still work, but are invisible to the schema, and the check reports them\n(",[326,775,776],{},"native-condition",").",[318,779,781],{"id":780},"two-closure-signatures","Two closure signatures",[331,783,784,797],{},[334,785,786],{},[337,787,788,791,794],{},[340,789,790],{},"Closure",[340,792,793],{},"Signature",[340,795,796],{},"When",[347,798,799,817],{},[337,800,801,810,814],{},[352,802,803,804,765,807],{},"a source, ",[326,805,806],{},"down:",[326,808,809],{},"up:",[352,811,812],{},[326,813,478],{},[352,815,816],{},"to read or convert a value",[337,818,819,825,830],{},[352,820,821,765,823],{},[326,822,610],{},[326,824,614],{},[352,826,827],{},[326,828,829],{},"($subject, $attribute)",[352,831,832],{},"before the value is read",[305,834,835],{},"Each may declare fewer parameters.",[837,838,839],"style",{},"html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":629,"searchDepth":711,"depth":711,"links":841},[842,843,844,845],{"id":320,"depth":668,"text":321},{"id":403,"depth":668,"text":404},{"id":524,"depth":668,"text":525},{"id":780,"depth":668,"text":781},"What a descriptor reads, on which subject, and the conditions that keep or omit a field.","md",{},true,"---\ntitle: Sources and conditions\ndescription: What a descriptor reads, on which subject, and the conditions that keep or omit a field.\n---\n\nA descriptor never holds a value. It says where to read one: its **source**, read on a **subject**.\n\n## The subject\n\nThe subject is what a declaration reads: the model of a `JsonResource`, each item of a list, the value of an object's\nsource.\n\n| Declaration | Subject of its children |\n| --- | --- |\n| a resource's `toArray()` | the resource's model (`$this->resource`) |\n| `Schema::object([...], 'shippingAddress')` | the value of `shippingAddress` |\n| `Schema::object([...])` | the parent's subject |\n| `Schema::list(Schema::object([...]), 'lines')` | each item of `lines` |\n\n## The source\n\nThe source is always the last argument of a helper:\n\n| Declaration | Reads |\n| --- | --- |\n| `'title' => Schema::string()` | `title`, the key the field is declared under (its head key, at every revision) |\n| `Schema::int('total_cents')` | the key `total_cents` |\n| `Schema::string('customer.name')` | a dotted path; `null` as soon as a segment is `null` |\n| `Schema::string(fn ($value, Order $order) => $order->fullName())` | the closure |\n\nA source closure receives `($value, $subject)` and may declare fewer parameters. `$value` is the value of the declared\nkey when the subject holds it without side effect (an existing offset, an initialized property, a loaded attribute or\nrelation), `null` otherwise: computing `$value` never triggers a lazy load or an accessor.\n\nA key or a path is read as `$model->key` would be: casts and accessors apply, and an unloaded relation is\nlazy-loaded. Guard a relation with `whenLoaded()`.\n\n::warning\n**A source is never an evaluated value.** The shapes are compiled once, without a real subject, and no source runs then.\nA string is always read as a key: `Schema::string($this->title)` reads the key *named by the title*. Write\n`Schema::string('title')` or a closure. Any other value (an int, a model) throws.\n::\n\n## Conditions\n\nA condition decides whether a field is rendered at all. A field refused by a condition is **omitted** (never `null`)\nand **never read**, so a condition can guard an expensive source.\n\n| Modifier | Keeps the field when |\n| --- | --- |\n| `whenHas(?string $key = null)` | the subject has the key (the declared key by default) |\n| `whenLoaded('customer')` | the relation is loaded |\n| `when(fn ($subject, $attribute) => ...)` | the closure returns `true` |\n| `unless(fn ($subject, $attribute) => ...)` | the closure returns `false` |\n\n`whenHas()` and `whenLoaded()` run first, then `when()` \u002F `unless()`, then the source. A condition closure receives\nthe subject and the key read (`'customer.name'` for `Schema::string('customer.name')`, else the declared key):\n\n```php\n'invoice_url' => Schema::string(\n    fn ($value, Order $order) => $order->invoiceUrl(),\n)\n    ->when(fn (Order $order) => $order->isPaid()),\n```\n\nA conditional field is optional in the export.\n\nPut conditions on the descriptor rather than using Laravel's native `$this->when()`, `mergeWhen()` or\n`$this->whenLoaded()`: those still work, but are invisible to the schema, and the check reports them\n(`native-condition`).\n\n## Two closure signatures\n\n| Closure | Signature | When |\n| --- | --- | --- |\n| a source, `down:`, `up:` | `($value, $subject)` | to read or convert a value |\n| `when()`, `unless()` | `($subject, $attribute)` | before the value is read |\n\nEach may declare fewer parameters.\n",{"title":164,"description":846},"nz9jda784O7mv-10nyAzWn8UlixREGH4aUjAERvrlaA",[854,856],{"title":160,"path":161,"stem":162,"description":855,"children":-1},"The typed descriptors a resource or a request is declared with, and their modifiers.",{"title":168,"path":169,"stem":170,"description":857,"children":-1},"Declare a JsonResource with descriptors and render it in the client's revision.",1795438905105]