[{"data":1,"prerenderedAt":1545},["ShallowReactive",2],{"navigation":3,"\u002Fsearch\u002Fexceptions-and-dates":173,"\u002Fsearch\u002Fexceptions-and-dates-surround":1540},[4,27,69,103,113,135],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":26},"Getting Started","i-heroicons-star","\u002Fgetting-started","1.getting-started",[10,14,18,22],{"title":11,"path":12,"stem":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction",{"title":15,"path":16,"stem":17},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation",{"title":19,"path":20,"stem":21},"Quick start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start",{"title":23,"path":24,"stem":25},"Upgrade guide","\u002Fgetting-started\u002Fupgrade-guide","1.getting-started\u002F5.upgrade-guide",false,{"title":28,"icon":29,"path":30,"stem":31,"children":32,"page":26},"Essentials","i-heroicons-shield-check","\u002Fessentials","2.essentials",[33,37,41,45,49,53,57,61,65],{"title":34,"path":35,"stem":36},"Controls","\u002Fessentials\u002Fcontrols","2.essentials\u002F1.controls",{"title":38,"path":39,"stem":40},"Perimeters","\u002Fessentials\u002Fperimeters","2.essentials\u002F2.perimeters",{"title":42,"path":43,"stem":44},"Perimeter classes","\u002Fessentials\u002Fperimeter-classes","2.essentials\u002F3.perimeter-classes",{"title":46,"path":47,"stem":48},"Levels","\u002Fessentials\u002Flevels","2.essentials\u002F4.levels",{"title":50,"path":51,"stem":52},"Boundaries","\u002Fessentials\u002Fboundaries","2.essentials\u002F5.boundaries",{"title":54,"path":55,"stem":56},"Parents","\u002Fessentials\u002Fparents","2.essentials\u002F6.parents",{"title":58,"path":59,"stem":60},"Policies","\u002Fessentials\u002Fpolicies","2.essentials\u002F7.policies",{"title":62,"path":63,"stem":64},"Queries","\u002Fessentials\u002Fqueries","2.essentials\u002F8.queries",{"title":66,"path":67,"stem":68},"Readers","\u002Fessentials\u002Freaders","2.essentials\u002F9.readers",{"title":70,"icon":71,"path":72,"stem":73,"children":74,"page":26},"Search","i-heroicons-magnifying-glass","\u002Fsearch","3.search",[75,79,83,87,91,95,99],{"title":76,"path":77,"stem":78},"Search overview","\u002Fsearch\u002Foverview","3.search\u002F1.overview",{"title":80,"path":81,"stem":82},"Engines","\u002Fsearch\u002Fengines","3.search\u002F2.engines",{"title":84,"path":85,"stem":86},"Keeping the keys fresh","\u002Fsearch\u002Fkeeping-the-keys-fresh","3.search\u002F3.keeping-the-keys-fresh",{"title":88,"path":89,"stem":90},"Exceptions and dates","\u002Fsearch\u002Fexceptions-and-dates","3.search\u002F4.exceptions-and-dates",{"title":92,"path":93,"stem":94},"Searching through a parent","\u002Fsearch\u002Fthrough-a-parent","3.search\u002F5.through-a-parent",{"title":96,"path":97,"stem":98},"Search from the browser","\u002Fsearch\u002Ffrom-the-browser","3.search\u002F6.from-the-browser",{"title":100,"path":101,"stem":102},"Your own search client","\u002Fsearch\u002Fyour-own-client","3.search\u002F7.your-own-client",{"title":104,"icon":105,"path":106,"stem":107,"children":108,"page":26},"Integrations","i-heroicons-puzzle-piece","\u002Fintegrations","4.integrations",[109],{"title":110,"path":111,"stem":112},"laravel-rest-api","\u002Fintegrations\u002Flaravel-rest-api","4.integrations\u002F1.laravel-rest-api",{"title":114,"icon":115,"path":116,"stem":117,"children":118,"page":26},"Testing and Tooling","i-heroicons-wrench-screwdriver","\u002Ftesting-and-tooling","5.testing-and-tooling",[119,123,127,131],{"title":120,"path":121,"stem":122},"Testing","\u002Ftesting-and-tooling\u002Ftesting","5.testing-and-tooling\u002F1.testing",{"title":124,"path":125,"stem":126},"access:check","\u002Ftesting-and-tooling\u002Faccess-check","5.testing-and-tooling\u002F2.access-check",{"title":128,"path":129,"stem":130},"Cache and about","\u002Ftesting-and-tooling\u002Fcache-and-about","5.testing-and-tooling\u002F3.cache-and-about",{"title":132,"path":133,"stem":134},"Generators","\u002Ftesting-and-tooling\u002Fgenerators","5.testing-and-tooling\u002F4.generators",{"title":136,"icon":137,"path":138,"stem":139,"children":140,"page":26},"Digging Deeper","i-heroicons-list-bullet","\u002Fdigging-deeper","6.digging-deeper",[141,145,149,153,157,161,165,169],{"title":142,"path":143,"stem":144},"Abilities","\u002Fdigging-deeper\u002Fabilities","6.digging-deeper\u002F1.abilities",{"title":146,"path":147,"stem":148},"Kept decisions","\u002Fdigging-deeper\u002Fdecisions","6.digging-deeper\u002F2.decisions",{"title":150,"path":151,"stem":152},"Batched decisions","\u002Fdigging-deeper\u002Fbatched-decisions","6.digging-deeper\u002F3.batched-decisions",{"title":154,"path":155,"stem":156},"Row checks","\u002Fdigging-deeper\u002Frow-checks","6.digging-deeper\u002F4.row-checks",{"title":158,"path":159,"stem":160},"Several brands","\u002Fdigging-deeper\u002Fseveral-brands","6.digging-deeper\u002F5.several-brands",{"title":162,"path":163,"stem":164},"Row context","\u002Fdigging-deeper\u002Frow-context","6.digging-deeper\u002F6.row-context",{"title":166,"path":167,"stem":168},"What is public in 1.x","\u002Fdigging-deeper\u002Fpublic-api","6.digging-deeper\u002F7.public-api",{"title":170,"path":171,"stem":172},"Use with AI","\u002Fdigging-deeper\u002Fuse-with-ai","6.digging-deeper\u002F8.use-with-ai",{"id":174,"title":88,"body":175,"description":1531,"extension":1532,"links":1533,"meta":1534,"navigation":1535,"path":89,"seo":1536,"sitemap":1537,"stem":90,"updatedAt":1538,"__hash__":1539},"docs\u002F3.search\u002F4.exceptions-and-dates.md",{"type":176,"value":177,"toc":1519},"minimark",[178,183,192,207,212,215,479,488,492,495,855,864,871,875,885,889,907,910,1397,1414,1418,1438,1470,1474,1480,1493,1497,1515],[179,180,182],"h2",{"id":181},"keys-only-add-rows","Keys only add rows",[184,185,186,187,191],"p",{},"A document is found when it shares a key with the reader, and nothing in the filter removes a document that a key found. There is ",[188,189,190],"strong",{},"no negative key",": a rule with an exception, such as a stand-in who sees the posts of the author they stand in for except some sectors or some posts, becomes a positive key.",[184,193,194,195,199,200,202,203,206],{},"A ",[196,197,198],"code",{},"whereNotIn"," would not do: a reader sees the union of what each of their perimeters grants, and a global ",[196,201,198],{}," would also remove the rows that another perimeter grants. A negation also fails open: a document indexed before its exclusion, or whose exclusion is not reindexed yet, does not carry the excluded value and passes a ",[196,204,205],{},"NOT IN",". A missing positive key hides the row instead.",[208,209,211],"h3",{"id":210},"an-exception-on-a-dimension-of-the-row","An exception on a dimension of the row",[184,213,214],{},"When the exception is on a finite dimension of the row, such as a sector, a category or a status, the reader gets the complement of their exclusions: one key per sector they may see.",[216,217,222],"pre",{"className":218,"code":219,"language":220,"meta":221,"style":221},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","StandInPerimeter::new()\n    \u002F\u002F allowed() and query() with the exclusions, as in SQL\n    ->searchKeys(\n        name: 'stand_in',\n        row: fn (Post $post) => [[$post->author_id, $post->sector_id]],\n        reader: fn (User $user) => $user->standingInFor->flatMap(\n            fn (StandIn $standIn) => array_map(fn (int $sector): array => [$standIn->principal_id, $sector], $standIn->allowedSectorIds()),\n        )->all(),\n    ),\n","php","",[196,223,224,244,251,263,285,342,382,461,473],{"__ignoreMap":221},[225,226,229,233,237,241],"span",{"class":227,"line":228},"line",1,[225,230,232],{"class":231},"sBMFI","StandInPerimeter",[225,234,236],{"class":235},"sMK4o","::",[225,238,240],{"class":239},"s2Zo4","new",[225,242,243],{"class":235},"()\n",[225,245,247],{"class":227,"line":246},2,[225,248,250],{"class":249},"sHwdD","    \u002F\u002F allowed() and query() with the exclusions, as in SQL\n",[225,252,254,257,260],{"class":227,"line":253},3,[225,255,256],{"class":235},"    ->",[225,258,259],{"class":239},"searchKeys",[225,261,262],{"class":235},"(\n",[225,264,266,269,272,275,279,282],{"class":227,"line":265},4,[225,267,268],{"class":231},"        name",[225,270,271],{"class":235},":",[225,273,274],{"class":235}," '",[225,276,278],{"class":277},"sfazB","stand_in",[225,280,281],{"class":235},"'",[225,283,284],{"class":235},",\n",[225,286,288,291,293,297,300,303,306,310,313,316,319,321,324,327,330,332,334,336,339],{"class":227,"line":287},5,[225,289,290],{"class":231},"        row",[225,292,271],{"class":235},[225,294,296],{"class":295},"spNyl"," fn",[225,298,299],{"class":235}," (",[225,301,302],{"class":231},"Post",[225,304,305],{"class":235}," $",[225,307,309],{"class":308},"sTEyZ","post",[225,311,312],{"class":235},")",[225,314,315],{"class":235}," =>",[225,317,318],{"class":235}," [[$",[225,320,309],{"class":308},[225,322,323],{"class":235},"->",[225,325,326],{"class":308},"author_id",[225,328,329],{"class":235},",",[225,331,305],{"class":235},[225,333,309],{"class":308},[225,335,323],{"class":235},[225,337,338],{"class":308},"sector_id",[225,340,341],{"class":235},"]],\n",[225,343,345,348,350,352,354,357,359,362,364,366,368,370,372,375,377,380],{"class":227,"line":344},6,[225,346,347],{"class":231},"        reader",[225,349,271],{"class":235},[225,351,296],{"class":295},[225,353,299],{"class":235},[225,355,356],{"class":231},"User",[225,358,305],{"class":235},[225,360,361],{"class":308},"user",[225,363,312],{"class":235},[225,365,315],{"class":235},[225,367,305],{"class":235},[225,369,361],{"class":308},[225,371,323],{"class":235},[225,373,374],{"class":308},"standingInFor",[225,376,323],{"class":235},[225,378,379],{"class":239},"flatMap",[225,381,262],{"class":235},[225,383,385,388,390,393,395,398,400,402,405,408,411,413,417,419,422,425,428,430,433,435,437,440,442,444,446,449,451,453,455,458],{"class":227,"line":384},7,[225,386,387],{"class":295},"            fn",[225,389,299],{"class":235},[225,391,392],{"class":231},"StandIn",[225,394,305],{"class":235},[225,396,397],{"class":308},"standIn",[225,399,312],{"class":235},[225,401,315],{"class":235},[225,403,404],{"class":239}," array_map",[225,406,407],{"class":235},"(",[225,409,410],{"class":295},"fn",[225,412,299],{"class":235},[225,414,416],{"class":415},"sbssI","int",[225,418,305],{"class":235},[225,420,421],{"class":308},"sector",[225,423,424],{"class":235},"):",[225,426,427],{"class":415}," array",[225,429,315],{"class":235},[225,431,432],{"class":235}," [$",[225,434,397],{"class":308},[225,436,323],{"class":235},[225,438,439],{"class":308},"principal_id",[225,441,329],{"class":235},[225,443,305],{"class":235},[225,445,421],{"class":308},[225,447,448],{"class":235},"],",[225,450,305],{"class":235},[225,452,397],{"class":308},[225,454,323],{"class":235},[225,456,457],{"class":239},"allowedSectorIds",[225,459,460],{"class":235},"()),\n",[225,462,464,467,470],{"class":227,"line":463},8,[225,465,466],{"class":235},"        )->",[225,468,469],{"class":239},"all",[225,471,472],{"class":235},"(),\n",[225,474,476],{"class":227,"line":475},9,[225,477,478],{"class":235},"    ),\n",[184,480,481,483,484,487],{},[196,482,374],{}," stands for the stand-ins the reader holds, and ",[196,485,486],{},"allowedSectorIds()"," for every sector of your application minus the ones the stand-in excludes. Nothing is reindexed when an exclusion changes, since the keys of a reader are computed at each search.",[208,489,491],{"id":490},"an-exception-on-specific-rows","An exception on specific rows",[184,493,494],{},"When the exception is on specific rows, such as a table of excluded posts, each row lists the readers who see it through the perimeter, and the reader has one key, their own id:",[216,496,498],{"className":218,"code":497,"language":220,"meta":221,"style":221},"StandInPerimeter::new()\n    \u002F\u002F allowed() and query() with the exclusions, as in SQL\n    ->searchKeys(\n        name: 'stand_in',\n        row: fn (Post $post) => $post->author->standIns\n            ->reject(fn (StandIn $standIn) => $standIn->excludes($post))\n            ->pluck('stand_in_id')\n            ->all(),\n        reader: fn (User $user) => $user->id,\n        load: ['author.standIns.exclusions'],\n    )\n    ->reindexWhen(StandIn::class, changed: ['principal_id', 'stand_in_id'], rows: fn (StandIn $standIn) => Post::where('author_id', $standIn->principal_id))\n    ->reindexWhen(StandInExclusion::class, changed: ['post_id'], rows: fn (StandInExclusion $exclusion) => Post::whereKey($exclusion->post_id)),\n",[196,499,500,510,514,522,536,570,611,630,638,669,690,696,785],{"__ignoreMap":221},[225,501,502,504,506,508],{"class":227,"line":228},[225,503,232],{"class":231},[225,505,236],{"class":235},[225,507,240],{"class":239},[225,509,243],{"class":235},[225,511,512],{"class":227,"line":246},[225,513,250],{"class":249},[225,515,516,518,520],{"class":227,"line":253},[225,517,256],{"class":235},[225,519,259],{"class":239},[225,521,262],{"class":235},[225,523,524,526,528,530,532,534],{"class":227,"line":265},[225,525,268],{"class":231},[225,527,271],{"class":235},[225,529,274],{"class":235},[225,531,278],{"class":277},[225,533,281],{"class":235},[225,535,284],{"class":235},[225,537,538,540,542,544,546,548,550,552,554,556,558,560,562,565,567],{"class":227,"line":287},[225,539,290],{"class":231},[225,541,271],{"class":235},[225,543,296],{"class":295},[225,545,299],{"class":235},[225,547,302],{"class":231},[225,549,305],{"class":235},[225,551,309],{"class":308},[225,553,312],{"class":235},[225,555,315],{"class":235},[225,557,305],{"class":235},[225,559,309],{"class":308},[225,561,323],{"class":235},[225,563,564],{"class":308},"author",[225,566,323],{"class":235},[225,568,569],{"class":308},"standIns\n",[225,571,572,575,578,580,582,584,586,588,590,592,594,596,598,600,603,606,608],{"class":227,"line":344},[225,573,574],{"class":235},"            ->",[225,576,577],{"class":239},"reject",[225,579,407],{"class":235},[225,581,410],{"class":295},[225,583,299],{"class":235},[225,585,392],{"class":231},[225,587,305],{"class":235},[225,589,397],{"class":308},[225,591,312],{"class":235},[225,593,315],{"class":235},[225,595,305],{"class":235},[225,597,397],{"class":308},[225,599,323],{"class":235},[225,601,602],{"class":239},"excludes",[225,604,605],{"class":235},"($",[225,607,309],{"class":308},[225,609,610],{"class":235},"))\n",[225,612,613,615,618,620,622,625,627],{"class":227,"line":384},[225,614,574],{"class":235},[225,616,617],{"class":239},"pluck",[225,619,407],{"class":235},[225,621,281],{"class":235},[225,623,624],{"class":277},"stand_in_id",[225,626,281],{"class":235},[225,628,629],{"class":235},")\n",[225,631,632,634,636],{"class":227,"line":463},[225,633,574],{"class":235},[225,635,469],{"class":239},[225,637,472],{"class":235},[225,639,640,642,644,646,648,650,652,654,656,658,660,662,664,667],{"class":227,"line":475},[225,641,347],{"class":231},[225,643,271],{"class":235},[225,645,296],{"class":295},[225,647,299],{"class":235},[225,649,356],{"class":231},[225,651,305],{"class":235},[225,653,361],{"class":308},[225,655,312],{"class":235},[225,657,315],{"class":235},[225,659,305],{"class":235},[225,661,361],{"class":308},[225,663,323],{"class":235},[225,665,666],{"class":308},"id",[225,668,284],{"class":235},[225,670,672,675,677,680,682,685,687],{"class":227,"line":671},10,[225,673,674],{"class":231},"        load",[225,676,271],{"class":235},[225,678,679],{"class":235}," [",[225,681,281],{"class":235},[225,683,684],{"class":277},"author.standIns.exclusions",[225,686,281],{"class":235},[225,688,689],{"class":235},"],\n",[225,691,693],{"class":227,"line":692},11,[225,694,695],{"class":235},"    )\n",[225,697,699,701,704,706,708,710,713,715,718,720,722,724,726,728,730,732,734,736,738,741,743,745,747,749,751,753,755,757,760,762,765,767,769,771,773,775,777,779,781,783],{"class":227,"line":698},12,[225,700,256],{"class":235},[225,702,703],{"class":239},"reindexWhen",[225,705,407],{"class":235},[225,707,392],{"class":231},[225,709,236],{"class":235},[225,711,712],{"class":415},"class",[225,714,329],{"class":235},[225,716,717],{"class":231}," changed",[225,719,271],{"class":235},[225,721,679],{"class":235},[225,723,281],{"class":235},[225,725,439],{"class":277},[225,727,281],{"class":235},[225,729,329],{"class":235},[225,731,274],{"class":235},[225,733,624],{"class":277},[225,735,281],{"class":235},[225,737,448],{"class":235},[225,739,740],{"class":231}," rows",[225,742,271],{"class":235},[225,744,296],{"class":295},[225,746,299],{"class":235},[225,748,392],{"class":231},[225,750,305],{"class":235},[225,752,397],{"class":308},[225,754,312],{"class":235},[225,756,315],{"class":235},[225,758,759],{"class":231}," Post",[225,761,236],{"class":235},[225,763,764],{"class":239},"where",[225,766,407],{"class":235},[225,768,281],{"class":235},[225,770,326],{"class":277},[225,772,281],{"class":235},[225,774,329],{"class":235},[225,776,305],{"class":235},[225,778,397],{"class":308},[225,780,323],{"class":235},[225,782,439],{"class":308},[225,784,610],{"class":235},[225,786,788,790,792,794,797,799,801,803,805,807,809,811,814,816,818,820,822,824,826,828,830,833,835,837,839,841,844,846,848,850,852],{"class":227,"line":787},13,[225,789,256],{"class":235},[225,791,703],{"class":239},[225,793,407],{"class":235},[225,795,796],{"class":231},"StandInExclusion",[225,798,236],{"class":235},[225,800,712],{"class":415},[225,802,329],{"class":235},[225,804,717],{"class":231},[225,806,271],{"class":235},[225,808,679],{"class":235},[225,810,281],{"class":235},[225,812,813],{"class":277},"post_id",[225,815,281],{"class":235},[225,817,448],{"class":235},[225,819,740],{"class":231},[225,821,271],{"class":235},[225,823,296],{"class":295},[225,825,299],{"class":235},[225,827,796],{"class":231},[225,829,305],{"class":235},[225,831,832],{"class":308},"exclusion",[225,834,312],{"class":235},[225,836,315],{"class":235},[225,838,759],{"class":231},[225,840,236],{"class":235},[225,842,843],{"class":239},"whereKey",[225,845,605],{"class":235},[225,847,832],{"class":308},[225,849,323],{"class":235},[225,851,813],{"class":308},[225,853,854],{"class":235},")),\n",[184,856,857,858,863],{},"A new stand-in reindexes the posts of the author, an exclusion reindexes one post. Until its job has run, the stand-in who excludes the post still finds it: see ",[859,860,862],"a",{"href":861},"\u002Fsearch\u002Fkeeping-the-keys-fresh#the-window","the window",".",[184,865,866,867,870],{},"When neither form fits, such as an exclusion that depends on the time, keep the model in SQL: search it with the ",[196,868,869],{},"database"," engine or with a controlled query.",[208,872,874],{"id":873},"testing-the-exceptions","Testing the exceptions",[184,876,877,878,884],{},"Check the recipe with ",[859,879,881],{"href":880},"\u002Ftesting-and-tooling\u002Ftesting#the-search",[196,882,883],{},"assertSearchAgrees()"," on a stand-in and rows that cover each case: rows of an excluded sector, an excluded row, and an excluded row that another perimeter grants, such as a post of a sector that the stand-in also manages. That last row must be found: it proves that the search keeps the union of the perimeters.",[179,886,888],{"id":887},"rights-that-depend-on-the-date","Rights that depend on the date",[184,890,891,892,902,903,906],{},"The keys of a row are computed when it is indexed, the keys of a reader at each search. ",[188,893,894,895,898,899,863],{},"Read the clock in ",[196,896,897],{},"reader",", never in ",[196,900,901],{},"row"," A row key computed from ",[196,904,905],{},"now()",", such as the users whose loan of a vehicle is active, stays in the index after the loan ends, and is missing before it starts, until the row is indexed again.",[184,908,909],{},"When the period ties the reader to something the row names without a date, such as a loan, an assignment to a site or a delegation from an author, key the row by that thing, and give the reader the ones whose period is active now:",[216,911,913],{"className":218,"code":912,"language":220,"meta":221,"style":221},"LoanPerimeter::new()\n    ->allowed(fn (User $user, Ability $ability) => $user->can(\"{$ability} borrowed vehicles\"))\n    ->query(fn (Builder $query, User $user) => $query->whereHas('loans', fn (Builder $loans) => $loans\n        ->whereBelongsTo($user)\n        ->where('starts_at', '\u003C=', now())\n        ->where(fn (Builder $end) => $end->whereNull('ends_at')->orWhere('ends_at', '>=', now()))))\n    ->searchKeys(\n        name: 'loan',\n        row: fn (Vehicle $vehicle) => $vehicle->getKey(),\n        reader: fn (User $user) => Loan::query()\n            ->whereBelongsTo($user)\n            ->where('starts_at', '\u003C=', now())\n            ->where(fn (Builder $end) => $end->whereNull('ends_at')->orWhere('ends_at', '>=', now()))\n            ->pluck('vehicle_id')\n            ->all(),\n    ),\n",[196,914,915,926,986,1058,1072,1104,1175,1183,1198,1231,1260,1272,1300,1365,1383,1392],{"__ignoreMap":221},[225,916,917,920,922,924],{"class":227,"line":228},[225,918,919],{"class":231},"LoanPerimeter",[225,921,236],{"class":235},[225,923,240],{"class":239},[225,925,243],{"class":235},[225,927,928,930,933,935,937,939,941,943,945,947,950,952,955,957,959,961,963,965,968,970,973,975,978,981,984],{"class":227,"line":246},[225,929,256],{"class":235},[225,931,932],{"class":239},"allowed",[225,934,407],{"class":235},[225,936,410],{"class":295},[225,938,299],{"class":235},[225,940,356],{"class":231},[225,942,305],{"class":235},[225,944,361],{"class":308},[225,946,329],{"class":235},[225,948,949],{"class":231}," Ability",[225,951,305],{"class":235},[225,953,954],{"class":308},"ability",[225,956,312],{"class":235},[225,958,315],{"class":235},[225,960,305],{"class":235},[225,962,361],{"class":308},[225,964,323],{"class":235},[225,966,967],{"class":239},"can",[225,969,407],{"class":235},[225,971,972],{"class":235},"\"{$",[225,974,954],{"class":308},[225,976,977],{"class":235},"}",[225,979,980],{"class":277}," borrowed vehicles",[225,982,983],{"class":235},"\"",[225,985,610],{"class":235},[225,987,988,990,993,995,997,999,1002,1004,1006,1008,1011,1013,1015,1017,1019,1021,1023,1025,1028,1030,1032,1035,1037,1039,1041,1043,1045,1047,1049,1051,1053,1055],{"class":227,"line":253},[225,989,256],{"class":235},[225,991,992],{"class":239},"query",[225,994,407],{"class":235},[225,996,410],{"class":295},[225,998,299],{"class":235},[225,1000,1001],{"class":231},"Builder",[225,1003,305],{"class":235},[225,1005,992],{"class":308},[225,1007,329],{"class":235},[225,1009,1010],{"class":231}," User",[225,1012,305],{"class":235},[225,1014,361],{"class":308},[225,1016,312],{"class":235},[225,1018,315],{"class":235},[225,1020,305],{"class":235},[225,1022,992],{"class":308},[225,1024,323],{"class":235},[225,1026,1027],{"class":239},"whereHas",[225,1029,407],{"class":235},[225,1031,281],{"class":235},[225,1033,1034],{"class":277},"loans",[225,1036,281],{"class":235},[225,1038,329],{"class":235},[225,1040,296],{"class":295},[225,1042,299],{"class":235},[225,1044,1001],{"class":231},[225,1046,305],{"class":235},[225,1048,1034],{"class":308},[225,1050,312],{"class":235},[225,1052,315],{"class":235},[225,1054,305],{"class":235},[225,1056,1057],{"class":308},"loans\n",[225,1059,1060,1063,1066,1068,1070],{"class":227,"line":265},[225,1061,1062],{"class":235},"        ->",[225,1064,1065],{"class":239},"whereBelongsTo",[225,1067,605],{"class":235},[225,1069,361],{"class":308},[225,1071,629],{"class":235},[225,1073,1074,1076,1078,1080,1082,1085,1087,1089,1091,1094,1096,1098,1101],{"class":227,"line":287},[225,1075,1062],{"class":235},[225,1077,764],{"class":239},[225,1079,407],{"class":235},[225,1081,281],{"class":235},[225,1083,1084],{"class":277},"starts_at",[225,1086,281],{"class":235},[225,1088,329],{"class":235},[225,1090,274],{"class":235},[225,1092,1093],{"class":277},"\u003C=",[225,1095,281],{"class":235},[225,1097,329],{"class":235},[225,1099,1100],{"class":239}," now",[225,1102,1103],{"class":235},"())\n",[225,1105,1106,1108,1110,1112,1114,1116,1118,1120,1123,1125,1127,1129,1131,1133,1136,1138,1140,1143,1145,1148,1151,1153,1155,1157,1159,1161,1163,1166,1168,1170,1172],{"class":227,"line":344},[225,1107,1062],{"class":235},[225,1109,764],{"class":239},[225,1111,407],{"class":235},[225,1113,410],{"class":295},[225,1115,299],{"class":235},[225,1117,1001],{"class":231},[225,1119,305],{"class":235},[225,1121,1122],{"class":308},"end",[225,1124,312],{"class":235},[225,1126,315],{"class":235},[225,1128,305],{"class":235},[225,1130,1122],{"class":308},[225,1132,323],{"class":235},[225,1134,1135],{"class":239},"whereNull",[225,1137,407],{"class":235},[225,1139,281],{"class":235},[225,1141,1142],{"class":277},"ends_at",[225,1144,281],{"class":235},[225,1146,1147],{"class":235},")->",[225,1149,1150],{"class":239},"orWhere",[225,1152,407],{"class":235},[225,1154,281],{"class":235},[225,1156,1142],{"class":277},[225,1158,281],{"class":235},[225,1160,329],{"class":235},[225,1162,274],{"class":235},[225,1164,1165],{"class":277},">=",[225,1167,281],{"class":235},[225,1169,329],{"class":235},[225,1171,1100],{"class":239},[225,1173,1174],{"class":235},"()))))\n",[225,1176,1177,1179,1181],{"class":227,"line":384},[225,1178,256],{"class":235},[225,1180,259],{"class":239},[225,1182,262],{"class":235},[225,1184,1185,1187,1189,1191,1194,1196],{"class":227,"line":463},[225,1186,268],{"class":231},[225,1188,271],{"class":235},[225,1190,274],{"class":235},[225,1192,1193],{"class":277},"loan",[225,1195,281],{"class":235},[225,1197,284],{"class":235},[225,1199,1200,1202,1204,1206,1208,1211,1213,1216,1218,1220,1222,1224,1226,1229],{"class":227,"line":475},[225,1201,290],{"class":231},[225,1203,271],{"class":235},[225,1205,296],{"class":295},[225,1207,299],{"class":235},[225,1209,1210],{"class":231},"Vehicle",[225,1212,305],{"class":235},[225,1214,1215],{"class":308},"vehicle",[225,1217,312],{"class":235},[225,1219,315],{"class":235},[225,1221,305],{"class":235},[225,1223,1215],{"class":308},[225,1225,323],{"class":235},[225,1227,1228],{"class":239},"getKey",[225,1230,472],{"class":235},[225,1232,1233,1235,1237,1239,1241,1243,1245,1247,1249,1251,1254,1256,1258],{"class":227,"line":671},[225,1234,347],{"class":231},[225,1236,271],{"class":235},[225,1238,296],{"class":295},[225,1240,299],{"class":235},[225,1242,356],{"class":231},[225,1244,305],{"class":235},[225,1246,361],{"class":308},[225,1248,312],{"class":235},[225,1250,315],{"class":235},[225,1252,1253],{"class":231}," Loan",[225,1255,236],{"class":235},[225,1257,992],{"class":239},[225,1259,243],{"class":235},[225,1261,1262,1264,1266,1268,1270],{"class":227,"line":692},[225,1263,574],{"class":235},[225,1265,1065],{"class":239},[225,1267,605],{"class":235},[225,1269,361],{"class":308},[225,1271,629],{"class":235},[225,1273,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292,1294,1296,1298],{"class":227,"line":698},[225,1275,574],{"class":235},[225,1277,764],{"class":239},[225,1279,407],{"class":235},[225,1281,281],{"class":235},[225,1283,1084],{"class":277},[225,1285,281],{"class":235},[225,1287,329],{"class":235},[225,1289,274],{"class":235},[225,1291,1093],{"class":277},[225,1293,281],{"class":235},[225,1295,329],{"class":235},[225,1297,1100],{"class":239},[225,1299,1103],{"class":235},[225,1301,1302,1304,1306,1308,1310,1312,1314,1316,1318,1320,1322,1324,1326,1328,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1352,1354,1356,1358,1360,1362],{"class":227,"line":787},[225,1303,574],{"class":235},[225,1305,764],{"class":239},[225,1307,407],{"class":235},[225,1309,410],{"class":295},[225,1311,299],{"class":235},[225,1313,1001],{"class":231},[225,1315,305],{"class":235},[225,1317,1122],{"class":308},[225,1319,312],{"class":235},[225,1321,315],{"class":235},[225,1323,305],{"class":235},[225,1325,1122],{"class":308},[225,1327,323],{"class":235},[225,1329,1135],{"class":239},[225,1331,407],{"class":235},[225,1333,281],{"class":235},[225,1335,1142],{"class":277},[225,1337,281],{"class":235},[225,1339,1147],{"class":235},[225,1341,1150],{"class":239},[225,1343,407],{"class":235},[225,1345,281],{"class":235},[225,1347,1142],{"class":277},[225,1349,281],{"class":235},[225,1351,329],{"class":235},[225,1353,274],{"class":235},[225,1355,1165],{"class":277},[225,1357,281],{"class":235},[225,1359,329],{"class":235},[225,1361,1100],{"class":239},[225,1363,1364],{"class":235},"()))\n",[225,1366,1368,1370,1372,1374,1376,1379,1381],{"class":227,"line":1367},14,[225,1369,574],{"class":235},[225,1371,617],{"class":239},[225,1373,407],{"class":235},[225,1375,281],{"class":235},[225,1377,1378],{"class":277},"vehicle_id",[225,1380,281],{"class":235},[225,1382,629],{"class":235},[225,1384,1386,1388,1390],{"class":227,"line":1385},15,[225,1387,574],{"class":235},[225,1389,469],{"class":239},[225,1391,472],{"class":235},[225,1393,1395],{"class":227,"line":1394},16,[225,1396,478],{"class":235},[184,1398,1399,1400,1403,1404,1406,1407,1409,1410,1413],{},"The document carries only the key of the vehicle, neither the user nor the dates, and nothing is reindexed when a period starts or ends. Write the same condition in ",[196,1401,1402],{},"query()"," and in ",[196,1405,897],{},", and compare with ",[196,1408,905],{}," from PHP rather than the database's ",[196,1411,1412],{},"NOW()",": a database clock in another time zone, or on another server, makes the SQL and the keys disagree.",[208,1415,1417],{"id":1416},"what-keeps-an-answer-longer","What keeps an answer longer",[184,1419,1420,1421,1424,1425,1428,1429,1433,1434,1437],{},"The keys of a reader follow the clock wherever they are computed at each search: ",[196,1422,1423],{},"controlled()",", ",[196,1426,1427],{},"controlledFor()",", a ",[859,1430,1432],{"href":1431},"\u002Fsearch\u002Ffrom-the-browser#through-a-route-of-the-application","guarded search",", laravel-rest-api and ",[196,1435,1436],{},"Access::indexReaderKeys()",". Three things keep an answer longer:",[1439,1440,1441,1448,1459],"ul",{},[1442,1443,194,1444,1447],"li",{},[859,1445,1446],{"href":97},"browser search token"," keeps the keys of the instant it was issued until it expires. Keep its expiry short.",[1442,1449,1450,1451,1454,1455,1458],{},"laravel-rest-api files a kept decision under the ",[196,1452,1453],{},"updated_at"," of the row, which the end of a period does not touch: leave the abilities that a period decides out of ",[196,1456,1457],{},"authorizationCache()",", or shorten their duration.",[1442,1460,1461,1462,1465,1466,1469],{},"A long-running console command keeps its ",[859,1463,1464],{"href":147},"decisions"," for its whole run. Call ",[196,1467,1468],{},"Access::forgetDecisions()"," at the start of each unit of work.",[208,1471,1473],{"id":1472},"when-the-period-belongs-to-the-row","When the period belongs to the row",[184,1475,1476,1477,1479],{},"When the period belongs to the row and many readers share it, such as the publication window of each post, the reader cannot list the rows: keep the model in SQL, with the ",[196,1478,869],{}," engine or a controlled query.",[184,1481,1482,1483,1485,1486,1488,1489,1492],{},"A window that only opens, such as an embargo lifted at a date, has a recipe of its own: a scheduled job writes the state into a column when the date passes, ",[196,1484,901],{}," and ",[196,1487,1402],{}," read that column, and the job reindexes the rows, through the save of the model or a ",[196,1490,1491],{},"reindexWhen()"," on the model it writes. A job that runs late keeps the rows closed a little longer, never open.",[208,1494,1496],{"id":1495},"testing-the-periods","Testing the periods",[184,1498,1499,1500,1504,1505,1508,1509,1485,1511,1514],{},"Test with ",[859,1501,1502],{"href":880},[196,1503,883],{}," before, during and after each period, and one second on each side of its bounds, with ",[196,1506,1507],{},"$this->travelTo()",". The documents do not depend on the clock, so the rows of the test are indexed once. ",[196,1510,883],{},[196,1512,1513],{},"assertIndexKeysAgree()"," fail when the keys of a row read the clock.",[1516,1517,1518],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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":221,"searchDepth":228,"depth":246,"links":1520},[1521,1526],{"id":181,"depth":246,"text":182,"children":1522},[1523,1524,1525],{"id":210,"depth":253,"text":211},{"id":490,"depth":253,"text":491},{"id":873,"depth":253,"text":874},{"id":887,"depth":246,"text":888,"children":1527},[1528,1529,1530],{"id":1416,"depth":253,"text":1417},{"id":1472,"depth":253,"text":1473},{"id":1495,"depth":253,"text":1496},"Write a rule with exceptions as positive search keys, and a right that holds during a period with the clock read on the reader side, never on the row side.","md",null,{},true,{"title":88,"description":1531},{"loc":89,"lastmod":1538},"2026-11-21T15:24:08+01:00","QxphdNZsu9W9D9UtQs5_gQhxHMdCF1kPyKMMEnwEHpI",[1541,1543],{"title":84,"path":85,"stem":86,"description":1542,"children":-1},"Search keys are computed at indexing time. Declare with reindexWhen() and ReindexesSearch what reindexes the documents when the data behind them changes.",{"title":92,"path":93,"stem":94,"description":1544,"children":-1},"A searchable child declared with ThroughParent is found through the keys of its parent, and its documents follow the changes of the parent.",1795277181440]