[{"data":1,"prerenderedAt":719},["ShallowReactive",2],{"navigation":3,"\u002Fdigging-deeper\u002Frow-checks":173,"\u002Fdigging-deeper\u002Frow-checks-surround":714},[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":154,"body":175,"description":706,"extension":707,"links":708,"meta":709,"navigation":399,"path":155,"seo":710,"sitemap":711,"stem":156,"updatedAt":712,"__hash__":713},"docs\u002F6.digging-deeper\u002F4.row-checks.md",{"type":176,"value":177,"toc":701},"minimark",[178,183,187,224,279,291,299,303,310,611,634,638,644,667,677,697],[179,180,182],"h2",{"id":181},"how-a-row-is-checked","How a row is checked",[184,185,186],"p",{},"The policy checks a saved row in a fixed order:",[188,189,190,203,217],"ol",{},[191,192,193,194,198,199,202],"li",{},"the in-memory form of the boundary: ",[195,196,197],"code",{},"Boundary::where()",", or the ",[195,200,201],{},"includes()"," hook of a boundary class;",[191,204,205,206,209,210,212,213,216],{},"the perimeters that check in memory: a ",[195,207,208],{},"should()"," callback, an ",[195,211,201],{}," hook, or ",[195,214,215],{},"unrestricted()",";",[191,218,219,220,223],{},"only when none of them grants, one SQL query on the row's key, constrained by the OR of the ",[195,221,222],{},"query()"," of every other perimeter the reader reaches, with the boundary inside it when it has no in-memory form.",[225,226,227,240],"table",{},[228,229,230],"thead",{},[231,232,233,237],"tr",{},[234,235,236],"th",{},"The reader reaches",[234,238,239],{},"Queries for one row",[241,242,243,255,263,271],"tbody",{},[231,244,245,249],{},[246,247,248],"td",{},"No perimeter",[246,250,251,252],{},"None: ",[195,253,254],{},"no_perimeter",[231,256,257,260],{},[246,258,259],{},"An unrestricted perimeter, with no boundary or a boundary with an in-memory form",[246,261,262],{},"None",[231,264,265,268],{},[246,266,267],{},"A perimeter with an in-memory form that contains the row",[246,269,270],{},"None, or one on the boundary when it has no in-memory form",[231,272,273,276],{},[246,274,275],{},"Only perimeters without an in-memory form",[246,277,278],{},"One, with the boundary in it when it has no in-memory form",[184,280,281,282,286,287,290],{},"The mode never depends on the state of the moment, such as loaded relations, so a decision costs the same number of queries in tests and in production. The SQL check of each row is ",[283,284,285],"a",{"href":147},"kept"," for the request, and the ",[283,288,289],{"href":151},"batched decisions"," decide many rows in one query.",[184,292,293,294,298],{},"A draft is not in the database: only the in-memory forms judge it, and a perimeter checked in SQL never grants it. See ",[283,295,297],{"href":296},"\u002Fessentials\u002Fpolicies#drafts","Drafts",".",[179,300,302],{"id":301},"which-perimeters-apply","Which perimeters apply",[184,304,305,306,309],{},"Inside a control, the protected ",[195,307,308],{},"applicablePerimeters($reader, $ability)"," lists the perimeters that apply to a reader for an ability: the level reached in each group, then the loose perimeters that allow the reader, or an unrestricted perimeter alone.",[311,312,317],"pre",{"className":313,"code":314,"language":315,"meta":316,"style":316},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","use Illuminate\\Database\\Eloquent\\Model;\nuse Lomkit\\Access\\Ability;\nuse Lomkit\\Access\\Perimeters\\Perimeter;\n\nclass PostControl extends Control\n{\n    public function grantingPerimeter(Model $reader, Post $post): ?Perimeter\n    {\n        foreach ($this->applicablePerimeters($reader, Ability::update()) as $perimeter) {\n            if ($perimeter->admits($reader, Ability::update(), $post)) {\n                return $perimeter;\n            }\n        }\n\n        return null;\n    }\n}\n","php","",[195,318,319,352,372,394,401,418,424,468,474,520,561,573,579,585,590,599,605],{"__ignoreMap":316},[320,321,324,328,332,336,339,341,344,346,349],"span",{"class":322,"line":323},"line",1,[320,325,327],{"class":326},"sbssI","use",[320,329,331],{"class":330},"sTEyZ"," Illuminate",[320,333,335],{"class":334},"sMK4o","\\",[320,337,338],{"class":330},"Database",[320,340,335],{"class":334},[320,342,343],{"class":330},"Eloquent",[320,345,335],{"class":334},[320,347,348],{"class":330},"Model",[320,350,351],{"class":334},";\n",[320,353,355,357,360,362,365,367,370],{"class":322,"line":354},2,[320,356,327],{"class":326},[320,358,359],{"class":330}," Lomkit",[320,361,335],{"class":334},[320,363,364],{"class":330},"Access",[320,366,335],{"class":334},[320,368,369],{"class":330},"Ability",[320,371,351],{"class":334},[320,373,375,377,379,381,383,385,387,389,392],{"class":322,"line":374},3,[320,376,327],{"class":326},[320,378,359],{"class":330},[320,380,335],{"class":334},[320,382,364],{"class":330},[320,384,335],{"class":334},[320,386,38],{"class":330},[320,388,335],{"class":334},[320,390,391],{"class":330},"Perimeter",[320,393,351],{"class":334},[320,395,397],{"class":322,"line":396},4,[320,398,400],{"emptyLinePlaceholder":399},true,"\n",[320,402,404,408,412,415],{"class":322,"line":403},5,[320,405,407],{"class":406},"spNyl","class",[320,409,411],{"class":410},"sBMFI"," PostControl",[320,413,414],{"class":406}," extends",[320,416,417],{"class":410}," Control\n",[320,419,421],{"class":322,"line":420},6,[320,422,423],{"class":334},"{\n",[320,425,427,430,433,437,440,442,445,448,451,454,456,459,462,465],{"class":322,"line":426},7,[320,428,429],{"class":406},"    public",[320,431,432],{"class":406}," function",[320,434,436],{"class":435},"s2Zo4"," grantingPerimeter",[320,438,439],{"class":334},"(",[320,441,348],{"class":410},[320,443,444],{"class":334}," $",[320,446,447],{"class":330},"reader",[320,449,450],{"class":334},",",[320,452,453],{"class":410}," Post",[320,455,444],{"class":334},[320,457,458],{"class":330},"post",[320,460,461],{"class":334},"):",[320,463,464],{"class":334}," ?",[320,466,467],{"class":410},"Perimeter\n",[320,469,471],{"class":322,"line":470},8,[320,472,473],{"class":334},"    {\n",[320,475,477,481,484,487,490,492,494,497,500,503,506,509,511,514,517],{"class":322,"line":476},9,[320,478,480],{"class":479},"s7zQu","        foreach",[320,482,483],{"class":334}," ($this->",[320,485,486],{"class":435},"applicablePerimeters",[320,488,489],{"class":334},"($",[320,491,447],{"class":330},[320,493,450],{"class":334},[320,495,496],{"class":410}," Ability",[320,498,499],{"class":334},"::",[320,501,502],{"class":435},"update",[320,504,505],{"class":334},"())",[320,507,508],{"class":334}," as",[320,510,444],{"class":334},[320,512,513],{"class":330},"perimeter",[320,515,516],{"class":334},")",[320,518,519],{"class":334}," {\n",[320,521,523,526,529,531,534,537,539,541,543,545,547,549,552,554,556,559],{"class":322,"line":522},10,[320,524,525],{"class":479},"            if",[320,527,528],{"class":334}," ($",[320,530,513],{"class":330},[320,532,533],{"class":334},"->",[320,535,536],{"class":435},"admits",[320,538,489],{"class":334},[320,540,447],{"class":330},[320,542,450],{"class":334},[320,544,496],{"class":410},[320,546,499],{"class":334},[320,548,502],{"class":435},[320,550,551],{"class":334},"(),",[320,553,444],{"class":334},[320,555,458],{"class":330},[320,557,558],{"class":334},"))",[320,560,519],{"class":334},[320,562,564,567,569,571],{"class":322,"line":563},11,[320,565,566],{"class":479},"                return",[320,568,444],{"class":334},[320,570,513],{"class":330},[320,572,351],{"class":334},[320,574,576],{"class":322,"line":575},12,[320,577,578],{"class":334},"            }\n",[320,580,582],{"class":322,"line":581},13,[320,583,584],{"class":334},"        }\n",[320,586,588],{"class":322,"line":587},14,[320,589,400],{"emptyLinePlaceholder":399},[320,591,593,596],{"class":322,"line":592},15,[320,594,595],{"class":479},"        return",[320,597,598],{"class":334}," null;\n",[320,600,602],{"class":322,"line":601},16,[320,603,604],{"class":334},"    }\n",[320,606,608],{"class":322,"line":607},17,[320,609,610],{"class":334},"}\n",[612,613,614,622,625],"ul",{},[191,615,616,617,621],{},"It reads the ",[283,618,620],{"href":619},"\u002Fdigging-deeper\u002Fdecisions#what-is-kept","kept perimeters"," of the reader, so it agrees with the policy and the queries.",[191,623,624],{},"It does not check the boundary against a row: the policy does.",[191,626,627,630,631,298],{},[195,628,629],{},"applicablePerimeters()"," is final. Give the methods you add to a control distinctive names, since a minor release may add methods to ",[195,632,633],{},"Control",[179,635,637],{"id":636},"which-perimeter-grants-a-row","Which perimeter grants a row",[184,639,640,643],{},[195,641,642],{},"$perimeter->admits($reader, $ability, $row)"," tells whether a perimeter applies to the reader for the ability and contains the row:",[612,645,646,655,664],{},[191,647,648,649,651,652,654],{},"in memory, through its ",[195,650,208],{}," callback or its ",[195,653,201],{}," hook;",[191,656,657,658,661,662,216],{},"otherwise with one ",[195,659,660],{},"exists"," query on the stored row, through its ",[195,663,222],{},[191,665,666],{},"never for an unsaved row, which only the in-memory checks judge.",[184,668,669,672,673,676],{},[195,670,671],{},"$perimeter->checksInMemory()"," tells which of the two it uses, and ",[195,674,675],{},"checksInMemory()"," on a boundary tells whether the boundary has an in-memory form.",[184,678,679,680,683,684,686,687,690,691,693,694,298],{},"Never call the hooks of another perimeter, ",[195,681,682],{},"allows()",", ",[195,685,201],{}," or ",[195,688,689],{},"scope()",", even though PHP lets a perimeter class do it: they skip the admission of the reader by the type of the callbacks and by the ",[195,692,447],{}," callback of the search keys. Call ",[195,695,696],{},"admits()",[698,699,700],"style",{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}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":316,"searchDepth":323,"depth":354,"links":702},[703,704,705],{"id":181,"depth":354,"text":182},{"id":301,"depth":354,"text":302},{"id":636,"depth":354,"text":637},"How the policy checks one row, in memory or in one SQL query, and how a control or a perimeter tells which perimeters apply and which one grants a row.","md",null,{},{"title":154,"description":706},{"loc":155,"lastmod":712},"2026-11-21T15:24:08+01:00","U5VZtaAG9deWy_7Apw9oUCbCoLXax9Q47-mfP072um8",[715,717],{"title":150,"path":151,"stem":152,"description":716,"children":-1},"Decide the rows of a page in one query with withAbilities(), preload decisions with Access::preload(), or get the keys a reader may act on with reachableKeys().",{"title":158,"path":159,"stem":160,"description":718,"children":-1},"List the rows of several brands, tenants or companies in one query with perimeters that read the brand of the row, and know when a parent needs the row's brand.",1795277182243]