[{"data":1,"prerenderedAt":1416},["ShallowReactive",2],{"navigation":3,"\u002Fgetting-started\u002Fintroduction":173,"\u002Fgetting-started\u002Fintroduction-surround":1413},[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":11,"body":175,"description":1405,"extension":1406,"links":1407,"meta":1408,"navigation":254,"path":12,"seo":1409,"sitemap":1410,"stem":13,"updatedAt":1411,"__hash__":1412},"docs\u002F1.getting-started\u002F1.introduction.md",{"type":176,"value":177,"toc":1393},"minimark",[178,183,212,936,939,984,997,1000,1121,1131,1135,1183,1187,1254,1258,1261,1266,1292,1296,1301,1305,1357,1361,1364,1373,1377,1389],[179,180,182],"h2",{"id":181},"what-it-is","What it is",[184,185,186,187,191,192,195,196,200,201,200,204,207,208,211],"p",{},"Laravel Access Control decides who can see and change which rows of your Eloquent models. For each model, you write one ",[188,189,190],"strong",{},"control",". Its ",[188,193,194],{},"perimeters"," say which users reach which rows, for each ability: ",[197,198,199],"code",{},"view",", ",[197,202,203],{},"update",[197,205,206],{},"delete",", or a business ability such as ",[197,209,210],{},"approve",".",[213,214,220],"pre",{"className":215,"code":216,"filename":217,"language":218,"meta":219,"style":219},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","namespace App\\Access\\Controls;\n\nuse App\\Access\\Perimeters\\ClientPerimeter;\nuse App\\Access\\Perimeters\\OwnPerimeter;\nuse App\\Models\\Post;\nuse App\\Models\\User;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Lomkit\\Access\\Ability;\nuse Lomkit\\Access\\Controls\\Control;\nuse Lomkit\\Access\\Perimeters\\Levels;\n\nclass PostControl extends Control\n{\n    protected string $model = Post::class;\n\n    protected function perimeters(): array\n    {\n        return [\n            Levels::of(\n                ClientPerimeter::new()\n                    ->allowed(fn (User $user, Ability $ability) => $user->client_id !== null && $user->can(\"{$ability} client posts\"))\n                    ->query(function (Builder $query, User $user): void {\n                        $query->where('client_id', $user->client_id);\n                    }),\n                OwnPerimeter::new()\n                    ->allowed(fn (User $user, Ability $ability) => $user->can(\"{$ability} own posts\"))\n                    ->should(fn (User $user, Post $post) => $post->author_id === $user->id)\n                    ->query(function (Builder $query, User $user): void {\n                        $query->where('author_id', $user->id);\n                    }),\n            ),\n        ];\n    }\n}\n","app\u002FAccess\u002FControls\u002FPostControl.php","php","",[197,221,222,249,256,280,302,321,339,364,383,405,426,431,447,453,481,486,504,510,520,534,548,638,677,713,719,731,785,842,875,907,912,918,924,930],{"__ignoreMap":219},[223,224,227,231,235,239,242,244,246],"span",{"class":225,"line":226},"line",1,[223,228,230],{"class":229},"sbssI","namespace",[223,232,234],{"class":233},"sBMFI"," App",[223,236,238],{"class":237},"sMK4o","\\",[223,240,241],{"class":233},"Access",[223,243,238],{"class":237},[223,245,34],{"class":233},[223,247,248],{"class":237},";\n",[223,250,252],{"class":225,"line":251},2,[223,253,255],{"emptyLinePlaceholder":254},true,"\n",[223,257,259,262,265,267,269,271,273,275,278],{"class":225,"line":258},3,[223,260,261],{"class":229},"use",[223,263,234],{"class":264},"sTEyZ",[223,266,238],{"class":237},[223,268,241],{"class":264},[223,270,238],{"class":237},[223,272,38],{"class":264},[223,274,238],{"class":237},[223,276,277],{"class":264},"ClientPerimeter",[223,279,248],{"class":237},[223,281,283,285,287,289,291,293,295,297,300],{"class":225,"line":282},4,[223,284,261],{"class":229},[223,286,234],{"class":264},[223,288,238],{"class":237},[223,290,241],{"class":264},[223,292,238],{"class":237},[223,294,38],{"class":264},[223,296,238],{"class":237},[223,298,299],{"class":264},"OwnPerimeter",[223,301,248],{"class":237},[223,303,305,307,309,311,314,316,319],{"class":225,"line":304},5,[223,306,261],{"class":229},[223,308,234],{"class":264},[223,310,238],{"class":237},[223,312,313],{"class":264},"Models",[223,315,238],{"class":237},[223,317,318],{"class":264},"Post",[223,320,248],{"class":237},[223,322,324,326,328,330,332,334,337],{"class":225,"line":323},6,[223,325,261],{"class":229},[223,327,234],{"class":264},[223,329,238],{"class":237},[223,331,313],{"class":264},[223,333,238],{"class":237},[223,335,336],{"class":264},"User",[223,338,248],{"class":237},[223,340,342,344,347,349,352,354,357,359,362],{"class":225,"line":341},7,[223,343,261],{"class":229},[223,345,346],{"class":264}," Illuminate",[223,348,238],{"class":237},[223,350,351],{"class":264},"Database",[223,353,238],{"class":237},[223,355,356],{"class":264},"Eloquent",[223,358,238],{"class":237},[223,360,361],{"class":264},"Builder",[223,363,248],{"class":237},[223,365,367,369,372,374,376,378,381],{"class":225,"line":366},8,[223,368,261],{"class":229},[223,370,371],{"class":264}," Lomkit",[223,373,238],{"class":237},[223,375,241],{"class":264},[223,377,238],{"class":237},[223,379,380],{"class":264},"Ability",[223,382,248],{"class":237},[223,384,386,388,390,392,394,396,398,400,403],{"class":225,"line":385},9,[223,387,261],{"class":229},[223,389,371],{"class":264},[223,391,238],{"class":237},[223,393,241],{"class":264},[223,395,238],{"class":237},[223,397,34],{"class":264},[223,399,238],{"class":237},[223,401,402],{"class":264},"Control",[223,404,248],{"class":237},[223,406,408,410,412,414,416,418,420,422,424],{"class":225,"line":407},10,[223,409,261],{"class":229},[223,411,371],{"class":264},[223,413,238],{"class":237},[223,415,241],{"class":264},[223,417,238],{"class":237},[223,419,38],{"class":264},[223,421,238],{"class":237},[223,423,46],{"class":264},[223,425,248],{"class":237},[223,427,429],{"class":225,"line":428},11,[223,430,255],{"emptyLinePlaceholder":254},[223,432,434,438,441,444],{"class":225,"line":433},12,[223,435,437],{"class":436},"spNyl","class",[223,439,440],{"class":233}," PostControl",[223,442,443],{"class":436}," extends",[223,445,446],{"class":233}," Control\n",[223,448,450],{"class":225,"line":449},13,[223,451,452],{"class":237},"{\n",[223,454,456,459,462,465,468,471,474,477,479],{"class":225,"line":455},14,[223,457,458],{"class":436},"    protected",[223,460,461],{"class":229}," string",[223,463,464],{"class":237}," $",[223,466,467],{"class":264},"model ",[223,469,470],{"class":237},"=",[223,472,473],{"class":233}," Post",[223,475,476],{"class":237},"::",[223,478,437],{"class":229},[223,480,248],{"class":237},[223,482,484],{"class":225,"line":483},15,[223,485,255],{"emptyLinePlaceholder":254},[223,487,489,491,494,498,501],{"class":225,"line":488},16,[223,490,458],{"class":436},[223,492,493],{"class":436}," function",[223,495,497],{"class":496},"s2Zo4"," perimeters",[223,499,500],{"class":237},"():",[223,502,503],{"class":229}," array\n",[223,505,507],{"class":225,"line":506},17,[223,508,509],{"class":237},"    {\n",[223,511,513,517],{"class":225,"line":512},18,[223,514,516],{"class":515},"s7zQu","        return",[223,518,519],{"class":237}," [\n",[223,521,523,526,528,531],{"class":225,"line":522},19,[223,524,525],{"class":233},"            Levels",[223,527,476],{"class":237},[223,529,530],{"class":496},"of",[223,532,533],{"class":237},"(\n",[223,535,537,540,542,545],{"class":225,"line":536},20,[223,538,539],{"class":233},"                ClientPerimeter",[223,541,476],{"class":237},[223,543,544],{"class":496},"new",[223,546,547],{"class":237},"()\n",[223,549,551,554,557,560,563,566,568,570,573,576,579,581,584,587,590,592,594,597,600,603,606,609,611,613,615,618,620,623,625,628,632,635],{"class":225,"line":550},21,[223,552,553],{"class":237},"                    ->",[223,555,556],{"class":496},"allowed",[223,558,559],{"class":237},"(",[223,561,562],{"class":436},"fn",[223,564,565],{"class":237}," (",[223,567,336],{"class":233},[223,569,464],{"class":237},[223,571,572],{"class":264},"user",[223,574,575],{"class":237},",",[223,577,578],{"class":233}," Ability",[223,580,464],{"class":237},[223,582,583],{"class":264},"ability",[223,585,586],{"class":237},")",[223,588,589],{"class":237}," =>",[223,591,464],{"class":237},[223,593,572],{"class":264},[223,595,596],{"class":237},"->",[223,598,599],{"class":264},"client_id ",[223,601,602],{"class":237},"!==",[223,604,605],{"class":237}," null",[223,607,608],{"class":237}," &&",[223,610,464],{"class":237},[223,612,572],{"class":264},[223,614,596],{"class":237},[223,616,617],{"class":496},"can",[223,619,559],{"class":237},[223,621,622],{"class":237},"\"{$",[223,624,583],{"class":264},[223,626,627],{"class":237},"}",[223,629,631],{"class":630},"sfazB"," client posts",[223,633,634],{"class":237},"\"",[223,636,637],{"class":237},"))\n",[223,639,641,643,646,648,651,653,655,657,659,661,664,666,668,671,674],{"class":225,"line":640},22,[223,642,553],{"class":237},[223,644,645],{"class":496},"query",[223,647,559],{"class":237},[223,649,650],{"class":436},"function",[223,652,565],{"class":237},[223,654,361],{"class":233},[223,656,464],{"class":237},[223,658,645],{"class":264},[223,660,575],{"class":237},[223,662,663],{"class":233}," User",[223,665,464],{"class":237},[223,667,572],{"class":264},[223,669,670],{"class":237},"):",[223,672,673],{"class":229}," void",[223,675,676],{"class":237}," {\n",[223,678,680,683,685,687,690,692,695,698,700,702,704,706,708,710],{"class":225,"line":679},23,[223,681,682],{"class":237},"                        $",[223,684,645],{"class":264},[223,686,596],{"class":237},[223,688,689],{"class":496},"where",[223,691,559],{"class":237},[223,693,694],{"class":237},"'",[223,696,697],{"class":630},"client_id",[223,699,694],{"class":237},[223,701,575],{"class":237},[223,703,464],{"class":237},[223,705,572],{"class":264},[223,707,596],{"class":237},[223,709,697],{"class":264},[223,711,712],{"class":237},");\n",[223,714,716],{"class":225,"line":715},24,[223,717,718],{"class":237},"                    }),\n",[223,720,722,725,727,729],{"class":225,"line":721},25,[223,723,724],{"class":233},"                OwnPerimeter",[223,726,476],{"class":237},[223,728,544],{"class":496},[223,730,547],{"class":237},[223,732,734,736,738,740,742,744,746,748,750,752,754,756,758,760,762,764,766,768,770,772,774,776,778,781,783],{"class":225,"line":733},26,[223,735,553],{"class":237},[223,737,556],{"class":496},[223,739,559],{"class":237},[223,741,562],{"class":436},[223,743,565],{"class":237},[223,745,336],{"class":233},[223,747,464],{"class":237},[223,749,572],{"class":264},[223,751,575],{"class":237},[223,753,578],{"class":233},[223,755,464],{"class":237},[223,757,583],{"class":264},[223,759,586],{"class":237},[223,761,589],{"class":237},[223,763,464],{"class":237},[223,765,572],{"class":264},[223,767,596],{"class":237},[223,769,617],{"class":496},[223,771,559],{"class":237},[223,773,622],{"class":237},[223,775,583],{"class":264},[223,777,627],{"class":237},[223,779,780],{"class":630}," own posts",[223,782,634],{"class":237},[223,784,637],{"class":237},[223,786,788,790,793,795,797,799,801,803,805,807,809,811,814,816,818,820,822,824,827,830,832,834,836,839],{"class":225,"line":787},27,[223,789,553],{"class":237},[223,791,792],{"class":496},"should",[223,794,559],{"class":237},[223,796,562],{"class":436},[223,798,565],{"class":237},[223,800,336],{"class":233},[223,802,464],{"class":237},[223,804,572],{"class":264},[223,806,575],{"class":237},[223,808,473],{"class":233},[223,810,464],{"class":237},[223,812,813],{"class":264},"post",[223,815,586],{"class":237},[223,817,589],{"class":237},[223,819,464],{"class":237},[223,821,813],{"class":264},[223,823,596],{"class":237},[223,825,826],{"class":264},"author_id ",[223,828,829],{"class":237},"===",[223,831,464],{"class":237},[223,833,572],{"class":264},[223,835,596],{"class":237},[223,837,838],{"class":264},"id",[223,840,841],{"class":237},")\n",[223,843,845,847,849,851,853,855,857,859,861,863,865,867,869,871,873],{"class":225,"line":844},28,[223,846,553],{"class":237},[223,848,645],{"class":496},[223,850,559],{"class":237},[223,852,650],{"class":436},[223,854,565],{"class":237},[223,856,361],{"class":233},[223,858,464],{"class":237},[223,860,645],{"class":264},[223,862,575],{"class":237},[223,864,663],{"class":233},[223,866,464],{"class":237},[223,868,572],{"class":264},[223,870,670],{"class":237},[223,872,673],{"class":229},[223,874,676],{"class":237},[223,876,878,880,882,884,886,888,890,893,895,897,899,901,903,905],{"class":225,"line":877},29,[223,879,682],{"class":237},[223,881,645],{"class":264},[223,883,596],{"class":237},[223,885,689],{"class":496},[223,887,559],{"class":237},[223,889,694],{"class":237},[223,891,892],{"class":630},"author_id",[223,894,694],{"class":237},[223,896,575],{"class":237},[223,898,464],{"class":237},[223,900,572],{"class":264},[223,902,596],{"class":237},[223,904,838],{"class":264},[223,906,712],{"class":237},[223,908,910],{"class":225,"line":909},30,[223,911,718],{"class":237},[223,913,915],{"class":225,"line":914},31,[223,916,917],{"class":237},"            ),\n",[223,919,921],{"class":225,"line":920},32,[223,922,923],{"class":237},"        ];\n",[223,925,927],{"class":225,"line":926},33,[223,928,929],{"class":237},"    }\n",[223,931,933],{"class":225,"line":932},34,[223,934,935],{"class":237},"}\n",[184,937,938],{},"Each perimeter answers up to three questions:",[940,941,942,955,965],"ul",{},[943,944,945,948,949,952,953,211],"li",{},[197,946,947],{},"allowed()"," is the ",[188,950,951],{},"permission",": does this perimeter apply to the user, for this ability? A user who may update the posts of their client reaches the client perimeter for ",[197,954,203],{},[943,956,957,960,961,964],{},[197,958,959],{},"query()"," gives the ",[188,962,963],{},"rows"," of the perimeter in SQL, for the lists.",[943,966,967,970,971,974,975,977,978,980,981,983],{},[197,968,969],{},"should()",", optional, checks ",[188,972,973],{},"one row"," in memory: when a user may only see their own posts, ",[197,976,969],{}," checks that the post at hand is theirs. ",[197,979,277],{}," has none: the package checks its rows through its ",[197,982,959],{},", in one SQL query.",[184,985,986,987,989,990,993,994,211],{},"The client perimeter refuses a user without a client in ",[197,988,947],{},", so that a ",[197,991,992],{},"null"," client never matches the posts without one. See ",[995,996,38],"a",{"href":39},[184,998,999],{},"The same control then answers everywhere:",[213,1001,1003],{"className":215,"code":1002,"language":218,"meta":219,"style":219},"$user->can('update', $post);                 \u002F\u002F the policy\nPost::query()->controlled()->paginate();     \u002F\u002F the posts the signed-in user may view\nPost::controlled('update')->count();         \u002F\u002F the posts they may update\nPost::search('budget')->controlled()->get(); \u002F\u002F a Laravel Scout search, with the same rules\n",[197,1004,1005,1037,1062,1089],{"__ignoreMap":219},[223,1006,1007,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1033],{"class":225,"line":226},[223,1008,1009],{"class":237},"$",[223,1011,572],{"class":264},[223,1013,596],{"class":237},[223,1015,617],{"class":496},[223,1017,559],{"class":237},[223,1019,694],{"class":237},[223,1021,203],{"class":630},[223,1023,694],{"class":237},[223,1025,575],{"class":237},[223,1027,464],{"class":237},[223,1029,813],{"class":264},[223,1031,1032],{"class":237},");",[223,1034,1036],{"class":1035},"sHwdD","                 \u002F\u002F the policy\n",[223,1038,1039,1041,1043,1045,1048,1051,1053,1056,1059],{"class":225,"line":251},[223,1040,318],{"class":233},[223,1042,476],{"class":237},[223,1044,645],{"class":496},[223,1046,1047],{"class":237},"()->",[223,1049,1050],{"class":496},"controlled",[223,1052,1047],{"class":237},[223,1054,1055],{"class":496},"paginate",[223,1057,1058],{"class":237},"();",[223,1060,1061],{"class":1035},"     \u002F\u002F the posts the signed-in user may view\n",[223,1063,1064,1066,1068,1070,1072,1074,1076,1078,1081,1084,1086],{"class":225,"line":258},[223,1065,318],{"class":233},[223,1067,476],{"class":237},[223,1069,1050],{"class":496},[223,1071,559],{"class":237},[223,1073,694],{"class":237},[223,1075,203],{"class":630},[223,1077,694],{"class":237},[223,1079,1080],{"class":237},")->",[223,1082,1083],{"class":496},"count",[223,1085,1058],{"class":237},[223,1087,1088],{"class":1035},"         \u002F\u002F the posts they may update\n",[223,1090,1091,1093,1095,1098,1100,1102,1105,1107,1109,1111,1113,1116,1118],{"class":225,"line":282},[223,1092,318],{"class":233},[223,1094,476],{"class":237},[223,1096,1097],{"class":496},"search",[223,1099,559],{"class":237},[223,1101,694],{"class":237},[223,1103,1104],{"class":630},"budget",[223,1106,694],{"class":237},[223,1108,1080],{"class":237},[223,1110,1050],{"class":496},[223,1112,1047],{"class":237},[223,1114,1115],{"class":496},"get",[223,1117,1058],{"class":237},[223,1119,1120],{"class":1035}," \u002F\u002F a Laravel Scout search, with the same rules\n",[184,1122,1123,1124,1127,1128,1130],{},"The search needs search keys on the perimeters and the ",[197,1125,1126],{},"ControlledSearchable"," trait on the model, as the ",[995,1129,70],{"href":77}," section shows.",[179,1132,1134],{"id":1133},"why-use-it","Why use it",[940,1136,1137,1151,1157,1174],{},[943,1138,1139,1142,1143,1146,1147,1150],{},[188,1140,1141],{},"One place for each rule."," The policy behind ",[197,1144,1145],{},"$user->can()",", the ",[197,1148,1149],{},"controlled()"," scope of your queries, the filter of your Scout searches and the row restriction of your laravel-rest-api resources all read the same control. A rule changed in the control changes everywhere.",[943,1152,1153,1156],{},[188,1154,1155],{},"Fails closed."," A query without a signed-in user, a user that no perimeter allows, or a boundary without a value gives no row. A missing or wrong declaration throws an exception instead of opening rows.",[943,1158,1159,1162,1163,1165,1166,1169,1170,1173],{},[188,1160,1161],{},"Built for real access models."," ",[995,1164,46],{"href":47}," apply the highest level a user reaches. A ",[995,1167,1168],{"href":51},"boundary"," keeps every row inside the user's tenant or workspace. A ",[995,1171,1172],{"href":55},"parent"," gives a comment the access of its post.",[943,1175,1176,1162,1179,1182],{},[188,1177,1178],{},"Checked.",[197,1180,1181],{},"php artisan access:check"," reports in CI what would throw, open or hide rows. Test assertions prove that the policy, the queries and the search agree on your test data.",[179,1184,1186],{"id":1185},"how-it-fits-laravel","How it fits Laravel",[940,1188,1189,1214,1234,1242],{},[943,1190,1191,1162,1194,1197,1198,200,1201,200,1204,1207,1208,1211,1212,211],{},[188,1192,1193],{},"Policies.",[197,1195,1196],{},"Access::registerPolicies()"," gives every controlled model a policy built on its control, unless the model has a policy of its own. ",[197,1199,1200],{},"can()",[197,1202,1203],{},"@can",[197,1205,1206],{},"authorize()"," and ",[197,1209,1210],{},"Gate::inspect()"," work as usual. See ",[995,1213,58],{"href":59},[943,1215,1216,1162,1219,200,1221,1207,1224,1227,1228,1231,1232,211],{},[188,1217,1218],{},"Eloquent.",[197,1220,1149],{},[197,1222,1223],{},"controlledFor()",[197,1225,1226],{},"uncontrolled()"," are local scopes of the ",[197,1229,1230],{},"HasControl"," trait. A query is controlled only when it says so: no global scope changes your other queries. See ",[995,1233,62],{"href":63},[943,1235,1236,1162,1239,1241],{},[188,1237,1238],{},"Laravel Scout.",[197,1240,1126],{}," indexes each document with the keys that open it, and a controlled search keeps the documents that the user may view, in one engine query.",[943,1243,1244,1247,1248,1253],{},[188,1245,1246],{},"Laravel Rest Api."," With ",[995,1249,110],{"href":1250,"rel":1251},"https:\u002F\u002Flaravel-rest-api.lomkit.com",[1252],"nofollow"," 3.6 or higher, an extension applies your controls to every resource of a controlled model, with no perimeter to write in the resources.",[179,1255,1257],{"id":1256},"when-to-use-it","When to use it",[184,1259,1260],{},"Laravel Access Control fits an application where users reach only some rows of a model: the rows of their tenant, of their client, of their team, or their own rows, with rights that differ by ability. It suits list screens, exports and searches that must show exactly the rows that the policy allows.",[1262,1263,1265],"h3",{"id":1264},"when-it-does-not-fit","When it does not fit",[940,1267,1268,1280,1286],{},[943,1269,1270,1273,1274,1276,1277,1279],{},[188,1271,1272],{},"Storing roles and permissions."," The package does not store roles or permissions. Your ",[197,1275,947],{}," callbacks read them from your application, such as ",[197,1278,1145],{}," with a permission package or your own tables.",[943,1281,1282,1285],{},[188,1283,1284],{},"Hiding columns."," A control decides which rows a user reaches, not which attributes of a row they see.",[943,1287,1288,1291],{},[188,1289,1290],{},"Every user sees every row."," When access depends on the ability alone, never on the row, a plain Laravel policy is enough.",[1262,1293,1295],{"id":1294},"requirements","Requirements",[184,1297,1298,1299,211],{},"Laravel Access Control requires PHP 8.3 or higher and Laravel 13. Laravel Scout and laravel-rest-api are optional, see ",[995,1300,15],{"href":16},[179,1302,1304],{"id":1303},"how-it-compares","How it compares",[940,1306,1307,1322,1340],{},[943,1308,1309,1312,1313,1318,1319,1321],{},[188,1310,1311],{},"Laravel policies and query scopes."," A ",[995,1314,1317],{"href":1315,"rel":1316},"https:\u002F\u002Flaravel.com\u002Fdocs\u002Fauthorization",[1252],"Laravel policy"," authorizes an action for a model or resource, and a local scope filters a query: written by hand, they are two places to keep in agreement. Laravel Access Control builds the policy and the ",[197,1320,1149],{}," scope from the same control, and gives the same rules to Laravel Scout.",[943,1323,1324,1162,1327,1332,1333,1335,1336,211],{},[188,1325,1326],{},"spatie\u002Flaravel-permission.",[995,1328,1331],{"href":1329,"rel":1330},"https:\u002F\u002Fspatie.be\u002Fdocs\u002Flaravel-permission",[1252],"spatie\u002Flaravel-permission"," manages user permissions and roles in a database. Laravel Access Control does not store them: its ",[197,1334,947],{}," callbacks can read the permissions that spatie\u002Flaravel-permission manages, so the two packages work together. With teams, put the current team in the ",[995,1337,1339],{"href":1338},"\u002Fessentials\u002Freaders#the-decision-context","decision context",[943,1341,1342,1162,1345,1350,1351,1353,1354,1356],{},[188,1343,1344],{},"PostgreSQL row-level security.",[995,1346,1349],{"href":1347,"rel":1348},"https:\u002F\u002Fwww.postgresql.org\u002Fdocs\u002Fcurrent\u002Fddl-rowsecurity.html",[1252],"Row security policies"," restrict, per database user, which rows a table returns or changes, for every query that reaches it, from Laravel or from any other client. Laravel Access Control works in the application: it filters only the queries that call ",[197,1352,1149],{}," or ",[197,1355,1223],{},", and the same control drives the policy and the Scout search, which the database does not reach.",[179,1358,1360],{"id":1359},"meet-lomkit","Meet Lomkit",[184,1362,1363],{},"Lomkit is an organization dedicated to the Laravel community. We offer a collection of open source packages for developers, and we keep them up to date with the latest practices of the framework.",[184,1365,1366,1367,1372],{},"Community contributions are welcome. Explore our packages on ",[995,1368,1371],{"href":1369,"rel":1370},"https:\u002F\u002Fgithub.com\u002Flomkit",[1252],"GitHub",", open an issue or send a pull request.",[179,1374,1376],{"id":1375},"next-steps","Next steps",[940,1378,1379,1384],{},[943,1380,1381,211],{},[995,1382,1383],{"href":16},"Install the package",[943,1385,1386,211],{},[995,1387,1388],{"href":20},"Control your first model",[1390,1391,1392],"style",{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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 .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}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 pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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);}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}",{"title":219,"searchDepth":226,"depth":251,"links":1394},[1395,1396,1397,1398,1402,1403,1404],{"id":181,"depth":251,"text":182},{"id":1133,"depth":251,"text":1134},{"id":1185,"depth":251,"text":1186},{"id":1256,"depth":251,"text":1257,"children":1399},[1400,1401],{"id":1264,"depth":258,"text":1265},{"id":1294,"depth":258,"text":1295},{"id":1303,"depth":251,"text":1304},{"id":1359,"depth":251,"text":1360},{"id":1375,"depth":251,"text":1376},"What Laravel Access Control does, how one control per model drives your policies, queries and searches, when it fits, and how it compares.","md",null,{},{"title":11,"description":1405},{"loc":12,"lastmod":1411},"2026-11-21T16:10:34+01:00","MYTAWPlQlGKRO-j3Y9a_HwIuMBdXl2BfoN_R7havnkI",[1407,1414],{"title":15,"path":16,"stem":17,"description":1415,"children":-1},"Requirements of Laravel Access Control 1.x and how to install it with Composer.",1795277179124]