[{"data":1,"prerenderedAt":1209},["ShallowReactive",2],{"navigation-zh":3,"navigation-v1":81,"\u002Fzh\u002Fguide\u002Fhooks":146,"\u002Fzh\u002Fguide\u002Fhooks-surround":732,"\u002Fzh\u002Fguide\u002Fhooks-og":737},[4,55,77],{"title":5,"path":6,"stem":7,"children":8},"指南","\u002Fzh\u002Fguide","zh\u002F1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43,47,51],{"title":10,"path":6,"stem":7},"介绍",{"title":12,"path":13,"stem":14},"序言","\u002Fzh\u002Fguide\u002Fprologue","zh\u002F1.guide\u002F00.prologue",{"title":16,"path":17,"stem":18},"快速上手","\u002Fzh\u002Fguide\u002Fgetting-started","zh\u002F1.guide\u002F02.getting-started",{"title":20,"path":21,"stem":22},"模型","\u002Fzh\u002Fguide\u002Fmodels","zh\u002F1.guide\u002F03.models",{"title":24,"path":25,"stem":26},"关联","\u002Fzh\u002Fguide\u002Frelationships","zh\u002F1.guide\u002F04.relationships",{"title":28,"path":29,"stem":30},"钩子","\u002Fzh\u002Fguide\u002Fhooks","zh\u002F1.guide\u002F05.hooks",{"title":32,"path":33,"stem":34},"搜索","\u002Fzh\u002Fguide\u002Fsearch","zh\u002F1.guide\u002F06.search",{"title":36,"path":37,"stem":38},"批量操作","\u002Fzh\u002Fguide\u002Fbatch-operations","zh\u002F1.guide\u002F07.batch-operations",{"title":40,"path":41,"stem":42},"查询参数","\u002Fzh\u002Fguide\u002Fquery-parameters","zh\u002F1.guide\u002F08.query-parameters",{"title":44,"path":45,"stem":46},"安全","\u002Fzh\u002Fguide\u002Fsecurity","zh\u002F1.guide\u002F09.security",{"title":48,"path":49,"stem":50},"响应","\u002Fzh\u002Fguide\u002Fresponses","zh\u002F1.guide\u002F10.responses",{"title":52,"path":53,"stem":54},"规范","\u002Fzh\u002Fguide\u002Fspecifications","zh\u002F1.guide\u002F11.specifications",{"title":56,"path":57,"stem":58,"children":59},"TypeScript SDK","\u002Fzh\u002Ftypescript-sdk","zh\u002F2.typescript-sdk\u002F01.index",[60,61,64,68,71,74],{"title":10,"path":57,"stem":58},{"title":16,"path":62,"stem":63},"\u002Fzh\u002Ftypescript-sdk\u002Fgetting-started","zh\u002F2.typescript-sdk\u002F02.getting-started",{"title":65,"path":66,"stem":67},"配置","\u002Fzh\u002Ftypescript-sdk\u002Fconfiguration","zh\u002F2.typescript-sdk\u002F03.configuration",{"title":20,"path":69,"stem":70},"\u002Fzh\u002Ftypescript-sdk\u002Fmodels","zh\u002F2.typescript-sdk\u002F04.models",{"title":24,"path":72,"stem":73},"\u002Fzh\u002Ftypescript-sdk\u002Frelationships","zh\u002F2.typescript-sdk\u002F05.relationships",{"title":40,"path":75,"stem":76},"\u002Fzh\u002Ftypescript-sdk\u002Fquery-parameters","zh\u002F2.typescript-sdk\u002F06.query-parameters",{"title":78,"path":79,"stem":80},"视频教程","\u002Fzh\u002Fscreencasts","zh\u002Fscreencasts",[82,125],{"title":83,"path":84,"stem":85,"children":86},"Guide","\u002Fv1.x\u002Fguide","v1.x\u002F1.guide\u002F01.index",[87,89,93,97,101,105,109,113,117,121],{"title":88,"path":84,"stem":85},"Introduction",{"title":90,"path":91,"stem":92},"Getting Started","\u002Fv1.x\u002Fguide\u002Fgetting-started","v1.x\u002F1.guide\u002F02.getting-started",{"title":94,"path":95,"stem":96},"Models","\u002Fv1.x\u002Fguide\u002Fmodels","v1.x\u002F1.guide\u002F03.models",{"title":98,"path":99,"stem":100},"Relationships","\u002Fv1.x\u002Fguide\u002Frelationships","v1.x\u002F1.guide\u002F04.relationships",{"title":102,"path":103,"stem":104},"Hooks","\u002Fv1.x\u002Fguide\u002Fhooks","v1.x\u002F1.guide\u002F05.hooks",{"title":106,"path":107,"stem":108},"Search","\u002Fv1.x\u002Fguide\u002Fsearch","v1.x\u002F1.guide\u002F06.search",{"title":110,"path":111,"stem":112},"Batch Operations","\u002Fv1.x\u002Fguide\u002Fbatch-operations","v1.x\u002F1.guide\u002F07.batch-operations",{"title":114,"path":115,"stem":116},"Query Parameters","\u002Fv1.x\u002Fguide\u002Fquery-parameters","v1.x\u002F1.guide\u002F08.query-parameters",{"title":118,"path":119,"stem":120},"Security","\u002Fv1.x\u002Fguide\u002Fsecurity","v1.x\u002F1.guide\u002F09.security",{"title":122,"path":123,"stem":124},"Responses","\u002Fv1.x\u002Fguide\u002Fresponses","v1.x\u002F1.guide\u002F10.responses",{"title":56,"path":126,"stem":127,"children":128},"\u002Fv1.x\u002Ftypescript-sdk","v1.x\u002F2.typescript-sdk\u002F01.index",[129,130,133,137,140,143],{"title":88,"path":126,"stem":127},{"title":90,"path":131,"stem":132},"\u002Fv1.x\u002Ftypescript-sdk\u002Fgetting-started","v1.x\u002F2.typescript-sdk\u002F02.getting-started",{"title":134,"path":135,"stem":136},"Configuration","\u002Fv1.x\u002Ftypescript-sdk\u002Fconfiguration","v1.x\u002F2.typescript-sdk\u002F03.configuration",{"title":94,"path":138,"stem":139},"\u002Fv1.x\u002Ftypescript-sdk\u002Fmodels","v1.x\u002F2.typescript-sdk\u002F04.models",{"title":98,"path":141,"stem":142},"\u002Fv1.x\u002Ftypescript-sdk\u002Frelationships","v1.x\u002F2.typescript-sdk\u002F05.relationships",{"title":114,"path":144,"stem":145},"\u002Fv1.x\u002Ftypescript-sdk\u002Fquery-parameters","v1.x\u002F2.typescript-sdk\u002F06.query-parameters",{"id":147,"title":28,"body":148,"description":726,"extension":727,"links":728,"meta":729,"navigation":187,"path":29,"seo":730,"stem":30,"__hash__":731},"docs_zh\u002Fzh\u002F1.guide\u002F05.hooks.md",{"type":149,"value":150,"toc":721},"minimark",[151,160,502,506,509,535,538,606,612,638,655,658,661,666,680,685,717],[152,153,154,155,159],"p",{},"这是一个常见的使用场景：假设你有一个用于博客文章的 API 控制器，每当创建一篇博客文章时，都需要将其与当前认证的用户关联起来。要实现这一点，只需添加一个 ",[156,157,158],"code",{},"beforeSave"," 钩子，并将用户与文章关联：",[161,162,167],"pre",{"className":163,"code":164,"language":165,"meta":166,"style":166},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003C?php\n\nnamespace App\\Http\\Controllers\\Api;\n\nuse App\\Models\\Post;\nuse Orion\\Http\\Requests\\Request;\nuse Orion\\Http\\Controllers\\Controller;\n\nclass PostsController extends Controller\n{\n    \u002F**\n     * @var string|null $model\n     *\u002F\n    protected $model = Post::class;\n\n    \u002F**\n     * @param Request $request\n     * @param Post $post\n     *\u002F\n    protected function beforeSave(Request $request, $post)\n    {\n        $post->user()->associate($request->user());\n    }\n}\n","php","",[156,168,169,182,189,219,224,243,267,289,294,310,316,323,346,352,377,382,387,402,414,419,452,458,490,496],{"__ignoreMap":166},[170,171,174,178],"span",{"class":172,"line":173},"line",1,[170,175,177],{"class":176},"sMK4o","\u003C?",[170,179,181],{"class":180},"sTEyZ","php\n",[170,183,185],{"class":172,"line":184},2,[170,186,188],{"emptyLinePlaceholder":187},true,"\n",[170,190,192,196,200,203,206,208,211,213,216],{"class":172,"line":191},3,[170,193,195],{"class":194},"sbssI","namespace",[170,197,199],{"class":198},"sBMFI"," App",[170,201,202],{"class":176},"\\",[170,204,205],{"class":198},"Http",[170,207,202],{"class":176},[170,209,210],{"class":198},"Controllers",[170,212,202],{"class":176},[170,214,215],{"class":198},"Api",[170,217,218],{"class":176},";\n",[170,220,222],{"class":172,"line":221},4,[170,223,188],{"emptyLinePlaceholder":187},[170,225,227,230,232,234,236,238,241],{"class":172,"line":226},5,[170,228,229],{"class":194},"use",[170,231,199],{"class":180},[170,233,202],{"class":176},[170,235,94],{"class":180},[170,237,202],{"class":176},[170,239,240],{"class":180},"Post",[170,242,218],{"class":176},[170,244,246,248,251,253,255,257,260,262,265],{"class":172,"line":245},6,[170,247,229],{"class":194},[170,249,250],{"class":180}," Orion",[170,252,202],{"class":176},[170,254,205],{"class":180},[170,256,202],{"class":176},[170,258,259],{"class":180},"Requests",[170,261,202],{"class":176},[170,263,264],{"class":180},"Request",[170,266,218],{"class":176},[170,268,270,272,274,276,278,280,282,284,287],{"class":172,"line":269},7,[170,271,229],{"class":194},[170,273,250],{"class":180},[170,275,202],{"class":176},[170,277,205],{"class":180},[170,279,202],{"class":176},[170,281,210],{"class":180},[170,283,202],{"class":176},[170,285,286],{"class":180},"Controller",[170,288,218],{"class":176},[170,290,292],{"class":172,"line":291},8,[170,293,188],{"emptyLinePlaceholder":187},[170,295,297,301,304,307],{"class":172,"line":296},9,[170,298,300],{"class":299},"spNyl","class",[170,302,303],{"class":198}," PostsController",[170,305,306],{"class":299}," extends",[170,308,309],{"class":198}," Controller\n",[170,311,313],{"class":172,"line":312},10,[170,314,315],{"class":176},"{\n",[170,317,319],{"class":172,"line":318},11,[170,320,322],{"class":321},"sHwdD","    \u002F**\n",[170,324,326,329,333,336,340,343],{"class":172,"line":325},12,[170,327,328],{"class":321},"     * ",[170,330,332],{"class":331},"svl4J","@var",[170,334,335],{"class":331}," string",[170,337,339],{"class":338},"s7zQu","|",[170,341,342],{"class":331},"null",[170,344,345],{"class":321}," $model\n",[170,347,349],{"class":172,"line":348},13,[170,350,351],{"class":321},"     *\u002F\n",[170,353,355,358,361,364,367,370,373,375],{"class":172,"line":354},14,[170,356,357],{"class":299},"    protected",[170,359,360],{"class":176}," $",[170,362,363],{"class":180},"model ",[170,365,366],{"class":176},"=",[170,368,369],{"class":198}," Post",[170,371,372],{"class":176},"::",[170,374,300],{"class":194},[170,376,218],{"class":176},[170,378,380],{"class":172,"line":379},15,[170,381,188],{"emptyLinePlaceholder":187},[170,383,385],{"class":172,"line":384},16,[170,386,322],{"class":321},[170,388,390,392,395,399],{"class":172,"line":389},17,[170,391,328],{"class":321},[170,393,394],{"class":331},"@param",[170,396,398],{"class":397},"sFweD"," Request",[170,400,401],{"class":321}," $request\n",[170,403,405,407,409,411],{"class":172,"line":404},18,[170,406,328],{"class":321},[170,408,394],{"class":331},[170,410,369],{"class":397},[170,412,413],{"class":321}," $post\n",[170,415,417],{"class":172,"line":416},19,[170,418,351],{"class":321},[170,420,422,424,427,431,434,436,438,441,444,446,449],{"class":172,"line":421},20,[170,423,357],{"class":299},[170,425,426],{"class":299}," function",[170,428,430],{"class":429},"s2Zo4"," beforeSave",[170,432,433],{"class":176},"(",[170,435,264],{"class":198},[170,437,360],{"class":176},[170,439,440],{"class":180},"request",[170,442,443],{"class":176},",",[170,445,360],{"class":176},[170,447,448],{"class":180},"post",[170,450,451],{"class":176},")\n",[170,453,455],{"class":172,"line":454},21,[170,456,457],{"class":176},"    {\n",[170,459,461,464,466,469,472,475,478,481,483,485,487],{"class":172,"line":460},22,[170,462,463],{"class":176},"        $",[170,465,448],{"class":180},[170,467,468],{"class":176},"->",[170,470,471],{"class":429},"user",[170,473,474],{"class":176},"()->",[170,476,477],{"class":429},"associate",[170,479,480],{"class":176},"($",[170,482,440],{"class":180},[170,484,468],{"class":176},[170,486,471],{"class":429},[170,488,489],{"class":176},"());\n",[170,491,493],{"class":172,"line":492},23,[170,494,495],{"class":176},"    }\n",[170,497,499],{"class":172,"line":498},24,[170,500,501],{"class":176},"}\n",[503,504,505],"h2",{"id":505},"事务",[152,507,508],{},"默认情况下，钩子中执行的查询以及操作本身的查询（例如更新一个实体）不会被包裹在事务中。你可以通过以下方式轻松改变这一行为：",[510,511,512,528],"ol",{},[513,514,515,516,519,520,523,524,527],"li",{},"在 ",[156,517,518],{},"orion.php"," 配置文件中将 ",[156,521,522],{},"transactions.enabled"," 设为 ",[156,525,526],{},"true","，这会影响所有控制器",[513,529,530,531,534],{},"在任意控制器上重写 ",[156,532,533],{},"transactionsAreEnabled"," 方法，以进行更细粒度的控制",[503,536,537],{"id":537},"模型控制器上的钩子",[539,540,541,544,547,550,553,556,559,562,565,576,586,589,592,595,598],"ul",{},[513,542,543],{},"beforeIndex - 在获取模型列表之前执行。",[513,545,546],{},"afterIndex - 在获取模型列表之后、构建响应之前执行。",[513,548,549],{},"beforeShow - 在获取模型之前执行。",[513,551,552],{},"afterShow - 在获取模型之后、构建响应之前执行。",[513,554,555],{},"beforeStore - 在创建新的模型实例并填充属性之前执行。",[513,557,558],{},"afterStore - 在保存模型之后、构建响应之前执行。",[513,560,561],{},"beforeUpdate - 在获取模型并填充属性之前执行。",[513,563,564],{},"afterUpdate - 在更新模型之后、构建响应之前执行。",[513,566,567,568,571,572,575],{},"beforeSave - 在模型保存之前执行，但在 ",[156,569,570],{},"beforeStore"," 和 ",[156,573,574],{},"beforeUpdate"," 之后。",[513,577,578,579,571,582,585],{},"afterSave - 在模型保存之后执行，但在 ",[156,580,581],{},"afterStore",[156,583,584],{},"afterUpdate"," 之前。",[513,587,588],{},"beforeDestroy - 在获取模型并删除它之前执行。",[513,590,591],{},"afterDestroy - 在删除模型之后、构建响应之前执行。",[513,593,594],{},"beforeRestore - 在获取模型并恢复它之前执行。",[513,596,597],{},"afterRestore - 在恢复模型之后、构建响应之前执行。",[513,599,600,601,571,604,585],{},"beforeFresh - 在保存后刷新模型之前执行，但在 ",[156,602,603],{},"afterSave",[156,605,581],{},[152,607,608],{},[609,610,611],"strong",{},"批量钩子：",[539,613,614,617,620,623,626,629,632,635],{},[513,615,616],{},"beforeBatchStore - 在创建新模型之前执行。",[513,618,619],{},"afterBatchStore - 在保存新模型之后、构建响应之前执行。",[513,621,622],{},"beforeBatchUpdate - 在获取待更新的模型之前执行。",[513,624,625],{},"afterBatchUpdate - 在更新模型之后、构建响应之前执行。",[513,627,628],{},"beforeBatchDestroy - 在获取待删除的模型之前执行。",[513,630,631],{},"afterBatchDestroy - 在删除模型之后、构建响应之前执行。",[513,633,634],{},"beforeBatchRestore - 在获取待恢复的模型之前执行。",[513,636,637],{},"afterBatchRestore - 在恢复模型之后、构建响应之前执行。",[639,640,641],"warning",{},[152,642,643,644,646,647,649,650,571,652,654],{},"在批量操作中，相关的 \"before\" 和 \"after\" 钩子（例如 ",[156,645,570],{},"、",[156,648,581],{},"）以及 ",[156,651,158],{},[156,653,603],{}," 也会对每个模型逐一执行。",[503,656,657],{"id":657},"关联控制器上的钩子",[152,659,660],{},"**所有类型：**关联控制器与模型控制器一样，为 CRUD 操作提供 before 和 after 钩子。",[152,662,663],{},[609,664,665],{},"一对多：",[539,667,668,671,674,677],{},[513,669,670],{},"beforeAssociate - 在获取两个模型之后、关联子模型之前执行。",[513,672,673],{},"afterAssociate - 在保存带有已关联子模型 id 的关联模型之后、构建响应之前执行。",[513,675,676],{},"beforeDissociate - 在获取两个模型之后、解除子模型关联之前执行。",[513,678,679],{},"afterDissociate - 在保存带有已关联子模型 id 的关联模型之后、构建响应之前执行。",[152,681,682],{},[609,683,684],{},"多对多：",[539,686,687,690,693,696,699,702,705,708,711,714],{},[513,688,689],{},"beforeSync - 在获取关联模型之前执行。",[513,691,692],{},"afterSync - 在同步相关模型之后、构建响应之前执行。",[513,694,695],{},"beforeToggle - 在获取关联模型之前执行。",[513,697,698],{},"afterToggle - 在切换相关模型之后、构建响应之前执行。",[513,700,701],{},"beforeAttach - 在获取关联模型之前执行。",[513,703,704],{},"afterAttach - 在将相关模型附加到关联模型之后、构建响应之前执行。",[513,706,707],{},"beforeDetach - 在获取关联模型之前执行。",[513,709,710],{},"afterDetach - 在将相关模型从关联模型分离之后、构建响应之前执行。",[513,712,713],{},"beforeUpdatePivot - 在获取关联模型之前执行。",[513,715,716],{},"afterUpdatePivot - 在更新相关模型的中间表数据之后、构建响应之前执行。",[718,719,720],"style",{},"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 .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 .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}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 .svl4J, html code.shiki .svl4J{--shiki-light:#F76D47;--shiki-light-font-style:italic;--shiki-default:#F78C6C;--shiki-default-font-style:italic;--shiki-dark:#F78C6C;--shiki-dark-font-style:italic}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 .sFweD, html code.shiki .sFweD{--shiki-light:#E2931D;--shiki-light-font-style:italic;--shiki-default:#FFCB6B;--shiki-default-font-style:italic;--shiki-dark:#FFCB6B;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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":166,"searchDepth":173,"depth":184,"links":722},[723,724,725],{"id":505,"depth":184,"text":505},{"id":537,"depth":184,"text":537},{"id":657,"depth":184,"text":657},"钩子（Hooks）是 Orion 的强大特性之一。它让你无需重写方法本身，即可介入某个端点（或多个端点）内部的执行流程。","md",null,{},{"title":28,"description":726},"9cPVDTxuFIUvCRiyqePN4GRj51AROwSsfhi-ggf8jno",[733,735],{"title":24,"path":25,"stem":26,"description":734,"children":-1},"了解如何通过 API 暴露模型关联。",{"title":32,"path":33,"stem":34,"description":736,"children":-1},"了解如何执行搜索、应用过滤、对结果排序、包含关联以及聚合数据。",{"id":738,"title":102,"body":739,"description":1203,"extension":727,"links":728,"meta":1204,"navigation":187,"path":1205,"seo":1206,"stem":1207,"__hash__":1208},"docs_en\u002F1.guide\u002F05.hooks.md",{"type":149,"value":740,"toc":1198},[741,747,991,995,998,1018,1022,1083,1088,1114,1130,1134,1140,1145,1159,1164,1196],[152,742,743,744,746],{},"Here is a common use case: imagine you have an API controller for blog posts and whenever a blog post is created, it needs to be associated with the currently authenticated user. To accomplish that, simply add a ",[156,745,158],{}," hook and associate a user with the post:",[161,748,749],{"className":163,"code":164,"language":165,"meta":166,"style":166},[156,750,751,757,761,781,785,801,821,841,845,855,859,863,877,881,899,903,907,917,927,931,955,959,983,987],{"__ignoreMap":166},[170,752,753,755],{"class":172,"line":173},[170,754,177],{"class":176},[170,756,181],{"class":180},[170,758,759],{"class":172,"line":184},[170,760,188],{"emptyLinePlaceholder":187},[170,762,763,765,767,769,771,773,775,777,779],{"class":172,"line":191},[170,764,195],{"class":194},[170,766,199],{"class":198},[170,768,202],{"class":176},[170,770,205],{"class":198},[170,772,202],{"class":176},[170,774,210],{"class":198},[170,776,202],{"class":176},[170,778,215],{"class":198},[170,780,218],{"class":176},[170,782,783],{"class":172,"line":221},[170,784,188],{"emptyLinePlaceholder":187},[170,786,787,789,791,793,795,797,799],{"class":172,"line":226},[170,788,229],{"class":194},[170,790,199],{"class":180},[170,792,202],{"class":176},[170,794,94],{"class":180},[170,796,202],{"class":176},[170,798,240],{"class":180},[170,800,218],{"class":176},[170,802,803,805,807,809,811,813,815,817,819],{"class":172,"line":245},[170,804,229],{"class":194},[170,806,250],{"class":180},[170,808,202],{"class":176},[170,810,205],{"class":180},[170,812,202],{"class":176},[170,814,259],{"class":180},[170,816,202],{"class":176},[170,818,264],{"class":180},[170,820,218],{"class":176},[170,822,823,825,827,829,831,833,835,837,839],{"class":172,"line":269},[170,824,229],{"class":194},[170,826,250],{"class":180},[170,828,202],{"class":176},[170,830,205],{"class":180},[170,832,202],{"class":176},[170,834,210],{"class":180},[170,836,202],{"class":176},[170,838,286],{"class":180},[170,840,218],{"class":176},[170,842,843],{"class":172,"line":291},[170,844,188],{"emptyLinePlaceholder":187},[170,846,847,849,851,853],{"class":172,"line":296},[170,848,300],{"class":299},[170,850,303],{"class":198},[170,852,306],{"class":299},[170,854,309],{"class":198},[170,856,857],{"class":172,"line":312},[170,858,315],{"class":176},[170,860,861],{"class":172,"line":318},[170,862,322],{"class":321},[170,864,865,867,869,871,873,875],{"class":172,"line":325},[170,866,328],{"class":321},[170,868,332],{"class":331},[170,870,335],{"class":331},[170,872,339],{"class":338},[170,874,342],{"class":331},[170,876,345],{"class":321},[170,878,879],{"class":172,"line":348},[170,880,351],{"class":321},[170,882,883,885,887,889,891,893,895,897],{"class":172,"line":354},[170,884,357],{"class":299},[170,886,360],{"class":176},[170,888,363],{"class":180},[170,890,366],{"class":176},[170,892,369],{"class":198},[170,894,372],{"class":176},[170,896,300],{"class":194},[170,898,218],{"class":176},[170,900,901],{"class":172,"line":379},[170,902,188],{"emptyLinePlaceholder":187},[170,904,905],{"class":172,"line":384},[170,906,322],{"class":321},[170,908,909,911,913,915],{"class":172,"line":389},[170,910,328],{"class":321},[170,912,394],{"class":331},[170,914,398],{"class":397},[170,916,401],{"class":321},[170,918,919,921,923,925],{"class":172,"line":404},[170,920,328],{"class":321},[170,922,394],{"class":331},[170,924,369],{"class":397},[170,926,413],{"class":321},[170,928,929],{"class":172,"line":416},[170,930,351],{"class":321},[170,932,933,935,937,939,941,943,945,947,949,951,953],{"class":172,"line":421},[170,934,357],{"class":299},[170,936,426],{"class":299},[170,938,430],{"class":429},[170,940,433],{"class":176},[170,942,264],{"class":198},[170,944,360],{"class":176},[170,946,440],{"class":180},[170,948,443],{"class":176},[170,950,360],{"class":176},[170,952,448],{"class":180},[170,954,451],{"class":176},[170,956,957],{"class":172,"line":454},[170,958,457],{"class":176},[170,960,961,963,965,967,969,971,973,975,977,979,981],{"class":172,"line":460},[170,962,463],{"class":176},[170,964,448],{"class":180},[170,966,468],{"class":176},[170,968,471],{"class":429},[170,970,474],{"class":176},[170,972,477],{"class":429},[170,974,480],{"class":176},[170,976,440],{"class":180},[170,978,468],{"class":176},[170,980,471],{"class":429},[170,982,489],{"class":176},[170,984,985],{"class":172,"line":492},[170,986,495],{"class":176},[170,988,989],{"class":172,"line":498},[170,990,501],{"class":176},[503,992,994],{"id":993},"transactions","Transactions",[152,996,997],{},"By default, queries executed in hooks and queries for an operation itself (e.g. updating an entity) are not wrapped in a transaction. You can easily change this behaviour by:",[510,999,1000,1012],{},[513,1001,1002,1003,1005,1006,1008,1009,1011],{},"Setting ",[156,1004,522],{}," to ",[156,1007,526],{}," in ",[156,1010,518],{}," config file, which would affect all controllers",[513,1013,1014,1015,1017],{},"Overriding ",[156,1016,533],{}," method on any controller for a more granular control",[503,1019,1021],{"id":1020},"on-model-controllers","On Model Controllers",[539,1023,1024,1027,1030,1033,1036,1039,1042,1045,1048,1057,1064,1067,1070,1073,1076],{},[513,1025,1026],{},"beforeIndex - executed before retrieving the list of models.",[513,1028,1029],{},"afterIndex - executed after retrieving the list of models, but before building response.",[513,1031,1032],{},"beforeShow - executed before retrieving a model.",[513,1034,1035],{},"afterShow - executed after retrieving a model, but before building response.",[513,1037,1038],{},"beforeStore - executed before creating a new model instance and filling out attributes.",[513,1040,1041],{},"afterStore - executed after storing a model, but before building response.",[513,1043,1044],{},"beforeUpdate - executed before retrieving a model and filling out attributes.",[513,1046,1047],{},"afterUpdate - executed after updating a model, but before building response.",[513,1049,1050,1051,1053,1054,1056],{},"beforeSave - executed before the model is saved, but after ",[156,1052,570],{}," and ",[156,1055,574],{},".",[513,1058,1059,1060,1053,1062,1056],{},"afterSave - executed after the model is saved, but before ",[156,1061,581],{},[156,1063,584],{},[513,1065,1066],{},"beforeDestroy - executed before retrieving a model and deleting it.",[513,1068,1069],{},"afterDestroy - executed after deleting a model, but before building response.",[513,1071,1072],{},"beforeRestore - executed before retrieving a model and restoring it.",[513,1074,1075],{},"afterRestore - executed after restoring a model, but before building response.",[513,1077,1078,1079,1053,1081,1056],{},"beforeFresh - executed before the model is refreshed after saving, but before ",[156,1080,603],{},[156,1082,581],{},[152,1084,1085],{},[609,1086,1087],{},"Batch hooks:",[539,1089,1090,1093,1096,1099,1102,1105,1108,1111],{},[513,1091,1092],{},"beforeBatchStore - executed before creating new models.",[513,1094,1095],{},"afterBatchStore - executed after storing new models, but before building response.",[513,1097,1098],{},"beforeBatchUpdate - executed before retrieving models for updating.",[513,1100,1101],{},"afterBatchUpdate - executed after updating the models, but before building response.",[513,1103,1104],{},"beforeBatchDestroy - executed before retrieving models for deleting.",[513,1106,1107],{},"afterBatchDestroy - executed after deleting the models, but before building response.",[513,1109,1110],{},"beforeBatchRestore - executed before retrieving models for restoring.",[513,1112,1113],{},"afterBatchRestore - executed after restoring the models, but before building response.",[639,1115,1116],{},[152,1117,1118,1119,1121,1122,1124,1125,1053,1127,1129],{},"Related \"before\" and \"after\" hooks (e.g. ",[156,1120,570],{},", ",[156,1123,581],{},") as well as ",[156,1126,158],{},[156,1128,603],{}," are also executed for each model in batch operations.",[503,1131,1133],{"id":1132},"on-relationship-controllers","On Relationship Controllers",[152,1135,1136,1139],{},[609,1137,1138],{},"All types:"," relation controllers have before and after hooks for CRUD operations - same as model controllers.",[152,1141,1142],{},[609,1143,1144],{},"One-to-many:",[539,1146,1147,1150,1153,1156],{},[513,1148,1149],{},"beforeAssociate - executed after retrieving both models, but before associating a child model.",[513,1151,1152],{},"afterAssociate - executed after saving a relation model with associated child model id, but before building response.",[513,1154,1155],{},"beforeDissociate - executed after retrieving both models, but before dissociating a child model.",[513,1157,1158],{},"afterDissociate - executed after saving a relation model with associated child model id, but before building response.",[152,1160,1161],{},[609,1162,1163],{},"Many-to-many:",[539,1165,1166,1169,1172,1175,1178,1181,1184,1187,1190,1193],{},[513,1167,1168],{},"beforeSync - executed before retrieving a relation model.",[513,1170,1171],{},"afterSync - executed after syncing related models, but before building response.",[513,1173,1174],{},"beforeToggle - executed before retrieving a relation model.",[513,1176,1177],{},"afterToggle - executed after toggling related models, but before building response.",[513,1179,1180],{},"beforeAttach - executed before retrieving a relation model.",[513,1182,1183],{},"afterAttach - executed after attaching related model(s) to a relation model, but before building response.",[513,1185,1186],{},"beforeDetach - executed before retrieving a relation model.",[513,1188,1189],{},"afterDetach - executed after detaching related model(s) from a relation model, but before building response.",[513,1191,1192],{},"beforeUpdatePivot - executed before retrieving a relation model.",[513,1194,1195],{},"afterUpdatePivot - executed after updating pivot of related model, but before building response.",[718,1197,720],{},{"title":166,"searchDepth":173,"depth":184,"links":1199},[1200,1201,1202],{"id":993,"depth":184,"text":994},{"id":1020,"depth":184,"text":1021},{"id":1132,"depth":184,"text":1133},"One of the powerful features of Orion is Hooks. It allows you to tap into the flow inside a particular endpoint (or multiple endpoints) without the need to override a method itself.",{},"\u002Fguide\u002Fhooks",{"title":102,"description":1203},"1.guide\u002F05.hooks","PrWT-kj6nNzG8J83GkNT2he6n8nIhWpAjkXtmn9lBPs",1784394463791]