[{"data":1,"prerenderedAt":1211},["ShallowReactive",2],{"navigation-ja":3,"navigation-v1":81,"\u002Fja\u002Fguide\u002Fhooks":146,"\u002Fja\u002Fguide\u002Fhooks-surround":734,"\u002Fja\u002Fguide\u002Fhooks-og":739},[4,55,77],{"title":5,"path":6,"stem":7,"children":8},"ガイド","\u002Fja\u002Fguide","ja\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},"プロローグ","\u002Fja\u002Fguide\u002Fprologue","ja\u002F1.guide\u002F00.prologue",{"title":16,"path":17,"stem":18},"はじめに","\u002Fja\u002Fguide\u002Fgetting-started","ja\u002F1.guide\u002F02.getting-started",{"title":20,"path":21,"stem":22},"モデル","\u002Fja\u002Fguide\u002Fmodels","ja\u002F1.guide\u002F03.models",{"title":24,"path":25,"stem":26},"リレーション","\u002Fja\u002Fguide\u002Frelationships","ja\u002F1.guide\u002F04.relationships",{"title":28,"path":29,"stem":30},"フック","\u002Fja\u002Fguide\u002Fhooks","ja\u002F1.guide\u002F05.hooks",{"title":32,"path":33,"stem":34},"検索","\u002Fja\u002Fguide\u002Fsearch","ja\u002F1.guide\u002F06.search",{"title":36,"path":37,"stem":38},"バッチ操作","\u002Fja\u002Fguide\u002Fbatch-operations","ja\u002F1.guide\u002F07.batch-operations",{"title":40,"path":41,"stem":42},"クエリパラメータ","\u002Fja\u002Fguide\u002Fquery-parameters","ja\u002F1.guide\u002F08.query-parameters",{"title":44,"path":45,"stem":46},"セキュリティ","\u002Fja\u002Fguide\u002Fsecurity","ja\u002F1.guide\u002F09.security",{"title":48,"path":49,"stem":50},"レスポンス","\u002Fja\u002Fguide\u002Fresponses","ja\u002F1.guide\u002F10.responses",{"title":52,"path":53,"stem":54},"仕様書","\u002Fja\u002Fguide\u002Fspecifications","ja\u002F1.guide\u002F11.specifications",{"title":56,"path":57,"stem":58,"children":59},"TypeScript SDK","\u002Fja\u002Ftypescript-sdk","ja\u002F2.typescript-sdk\u002F01.index",[60,61,64,68,71,74],{"title":10,"path":57,"stem":58},{"title":16,"path":62,"stem":63},"\u002Fja\u002Ftypescript-sdk\u002Fgetting-started","ja\u002F2.typescript-sdk\u002F02.getting-started",{"title":65,"path":66,"stem":67},"設定","\u002Fja\u002Ftypescript-sdk\u002Fconfiguration","ja\u002F2.typescript-sdk\u002F03.configuration",{"title":20,"path":69,"stem":70},"\u002Fja\u002Ftypescript-sdk\u002Fmodels","ja\u002F2.typescript-sdk\u002F04.models",{"title":24,"path":72,"stem":73},"\u002Fja\u002Ftypescript-sdk\u002Frelationships","ja\u002F2.typescript-sdk\u002F05.relationships",{"title":40,"path":75,"stem":76},"\u002Fja\u002Ftypescript-sdk\u002Fquery-parameters","ja\u002F2.typescript-sdk\u002F06.query-parameters",{"title":78,"path":79,"stem":80},"スクリーンキャスト","\u002Fja\u002Fscreencasts","ja\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":728,"extension":729,"links":730,"meta":731,"navigation":187,"path":29,"seo":732,"stem":30,"__hash__":733},"docs_ja\u002Fja\u002F1.guide\u002F05.hooks.md",{"type":149,"value":150,"toc":723},"minimark",[151,160,502,506,509,534,537,605,611,637,654,657,663,668,682,687,719],[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,527],"ol",{},[513,514,515,518,519,522,523,526],"li",{},[156,516,517],{},"orion.php","設定ファイルで",[156,520,521],{},"transactions.enabled","を",[156,524,525],{},"true","に設定します。これはすべてのコントローラーに影響します",[513,528,529,530,533],{},"より細かく制御するには、任意のコントローラーで",[156,531,532],{},"transactionsAreEnabled","メソッドをオーバーライドします",[503,535,536],{"id":536},"モデルコントローラーのフック",[538,539,540,543,546,549,552,555,558,561,564,575,585,588,591,594,597],"ul",{},[513,541,542],{},"beforeIndex - モデルの一覧を取得する前に実行されます。",[513,544,545],{},"afterIndex - モデルの一覧を取得した後、レスポンスを構築する前に実行されます。",[513,547,548],{},"beforeShow - モデルを取得する前に実行されます。",[513,550,551],{},"afterShow - モデルを取得した後、レスポンスを構築する前に実行されます。",[513,553,554],{},"beforeStore - 新しいモデルインスタンスを作成して属性を設定する前に実行されます。",[513,556,557],{},"afterStore - モデルを保存した後、レスポンスを構築する前に実行されます。",[513,559,560],{},"beforeUpdate - モデルを取得して属性を設定する前に実行されます。",[513,562,563],{},"afterUpdate - モデルを更新した後、レスポンスを構築する前に実行されます。",[513,565,566,567,570,571,574],{},"beforeSave - モデルが保存される前、ただし",[156,568,569],{},"beforeStore","および",[156,572,573],{},"beforeUpdate","の後に実行されます。",[513,576,577,578,570,581,584],{},"afterSave - モデルが保存された後、ただし",[156,579,580],{},"afterStore",[156,582,583],{},"afterUpdate","の前に実行されます。",[513,586,587],{},"beforeDestroy - モデルを取得して削除する前に実行されます。",[513,589,590],{},"afterDestroy - モデルを削除した後、レスポンスを構築する前に実行されます。",[513,592,593],{},"beforeRestore - モデルを取得して復元する前に実行されます。",[513,595,596],{},"afterRestore - モデルを復元した後、レスポンスを構築する前に実行されます。",[513,598,599,600,570,603,584],{},"beforeFresh - 保存後にモデルがリフレッシュされる前、かつ",[156,601,602],{},"afterSave",[156,604,580],{},[152,606,607],{},[608,609,610],"strong",{},"バッチ操作のフック:",[538,612,613,616,619,622,625,628,631,634],{},[513,614,615],{},"beforeBatchStore - 新しいモデルを作成する前に実行されます。",[513,617,618],{},"afterBatchStore - 新しいモデルを保存した後、レスポンスを構築する前に実行されます。",[513,620,621],{},"beforeBatchUpdate - 更新対象のモデルを取得する前に実行されます。",[513,623,624],{},"afterBatchUpdate - モデルを更新した後、レスポンスを構築する前に実行されます。",[513,626,627],{},"beforeBatchDestroy - 削除対象のモデルを取得する前に実行されます。",[513,629,630],{},"afterBatchDestroy - モデルを削除した後、レスポンスを構築する前に実行されます。",[513,632,633],{},"beforeBatchRestore - 復元対象のモデルを取得する前に実行されます。",[513,635,636],{},"afterBatchRestore - モデルを復元した後、レスポンスを構築する前に実行されます。",[638,639,640],"warning",{},[152,641,642,643,645,646,648,649,570,651,653],{},"対応する「before」および「after」フック(たとえば",[156,644,569],{},"、",[156,647,580],{},")と、",[156,650,158],{},[156,652,602],{},"は、バッチ操作でも各モデルごとに実行されます。",[503,655,656],{"id":656},"リレーションコントローラーのフック",[152,658,659,662],{},[608,660,661],{},"全タイプ共通:"," リレーションコントローラーには、モデルコントローラーと同様に、CRUD操作のbeforeフックとafterフックがあります。",[152,664,665],{},[608,666,667],{},"1対多:",[538,669,670,673,676,679],{},[513,671,672],{},"beforeAssociate - 両方のモデルを取得した後、子モデルを関連付ける前に実行されます。",[513,674,675],{},"afterAssociate - 関連付けられた子モデルのidとともにリレーションモデルを保存した後、レスポンスを構築する前に実行されます。",[513,677,678],{},"beforeDissociate - 両方のモデルを取得した後、子モデルの関連付けを解除する前に実行されます。",[513,680,681],{},"afterDissociate - 関連付けられた子モデルのidとともにリレーションモデルを保存した後、レスポンスを構築する前に実行されます。",[152,683,684],{},[608,685,686],{},"多対多:",[538,688,689,692,695,698,701,704,707,710,713,716],{},[513,690,691],{},"beforeSync - リレーションモデルを取得する前に実行されます。",[513,693,694],{},"afterSync - 関連モデルをsyncした後、レスポンスを構築する前に実行されます。",[513,696,697],{},"beforeToggle - リレーションモデルを取得する前に実行されます。",[513,699,700],{},"afterToggle - 関連モデルをtoggleした後、レスポンスを構築する前に実行されます。",[513,702,703],{},"beforeAttach - リレーションモデルを取得する前に実行されます。",[513,705,706],{},"afterAttach - 関連モデルをリレーションモデルにattachした後、レスポンスを構築する前に実行されます。",[513,708,709],{},"beforeDetach - リレーションモデルを取得する前に実行されます。",[513,711,712],{},"afterDetach - 関連モデルをリレーションモデルからdetachした後、レスポンスを構築する前に実行されます。",[513,714,715],{},"beforeUpdatePivot - リレーションモデルを取得する前に実行されます。",[513,717,718],{},"afterUpdatePivot - 関連モデルのピボットを更新した後、レスポンスを構築する前に実行されます。",[720,721,722],"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":724},[725,726,727],{"id":505,"depth":184,"text":505},{"id":536,"depth":184,"text":536},{"id":656,"depth":184,"text":656},"Orionの強力な機能のひとつがフックです。メソッド自体をオーバーライドすることなく、特定のエンドポイント(または複数のエンドポイント)内の処理フローに割り込むことができます。","md",null,{},{"title":28,"description":728},"F3EDQZR504ywD5F_LZ8tflDLj8Fmpk3cGeQOAn7Vkg4",[735,737],{"title":24,"path":25,"stem":26,"description":736,"children":-1},"モデルのリレーションをAPI経由で公開する方法を学びます。",{"title":32,"path":33,"stem":34,"description":738,"children":-1},"検索の実行、フィルタの適用、結果のソート、リレーションのインクルード、データの集計の方法を学びます。",{"id":740,"title":102,"body":741,"description":1205,"extension":729,"links":730,"meta":1206,"navigation":187,"path":1207,"seo":1208,"stem":1209,"__hash__":1210},"docs_en\u002F1.guide\u002F05.hooks.md",{"type":149,"value":742,"toc":1200},[743,749,993,997,1000,1020,1024,1085,1090,1116,1132,1136,1142,1147,1161,1166,1198],[152,744,745,746,748],{},"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,747,158],{}," hook and associate a user with the post:",[161,750,751],{"className":163,"code":164,"language":165,"meta":166,"style":166},[156,752,753,759,763,783,787,803,823,843,847,857,861,865,879,883,901,905,909,919,929,933,957,961,985,989],{"__ignoreMap":166},[170,754,755,757],{"class":172,"line":173},[170,756,177],{"class":176},[170,758,181],{"class":180},[170,760,761],{"class":172,"line":184},[170,762,188],{"emptyLinePlaceholder":187},[170,764,765,767,769,771,773,775,777,779,781],{"class":172,"line":191},[170,766,195],{"class":194},[170,768,199],{"class":198},[170,770,202],{"class":176},[170,772,205],{"class":198},[170,774,202],{"class":176},[170,776,210],{"class":198},[170,778,202],{"class":176},[170,780,215],{"class":198},[170,782,218],{"class":176},[170,784,785],{"class":172,"line":221},[170,786,188],{"emptyLinePlaceholder":187},[170,788,789,791,793,795,797,799,801],{"class":172,"line":226},[170,790,229],{"class":194},[170,792,199],{"class":180},[170,794,202],{"class":176},[170,796,94],{"class":180},[170,798,202],{"class":176},[170,800,240],{"class":180},[170,802,218],{"class":176},[170,804,805,807,809,811,813,815,817,819,821],{"class":172,"line":245},[170,806,229],{"class":194},[170,808,250],{"class":180},[170,810,202],{"class":176},[170,812,205],{"class":180},[170,814,202],{"class":176},[170,816,259],{"class":180},[170,818,202],{"class":176},[170,820,264],{"class":180},[170,822,218],{"class":176},[170,824,825,827,829,831,833,835,837,839,841],{"class":172,"line":269},[170,826,229],{"class":194},[170,828,250],{"class":180},[170,830,202],{"class":176},[170,832,205],{"class":180},[170,834,202],{"class":176},[170,836,210],{"class":180},[170,838,202],{"class":176},[170,840,286],{"class":180},[170,842,218],{"class":176},[170,844,845],{"class":172,"line":291},[170,846,188],{"emptyLinePlaceholder":187},[170,848,849,851,853,855],{"class":172,"line":296},[170,850,300],{"class":299},[170,852,303],{"class":198},[170,854,306],{"class":299},[170,856,309],{"class":198},[170,858,859],{"class":172,"line":312},[170,860,315],{"class":176},[170,862,863],{"class":172,"line":318},[170,864,322],{"class":321},[170,866,867,869,871,873,875,877],{"class":172,"line":325},[170,868,328],{"class":321},[170,870,332],{"class":331},[170,872,335],{"class":331},[170,874,339],{"class":338},[170,876,342],{"class":331},[170,878,345],{"class":321},[170,880,881],{"class":172,"line":348},[170,882,351],{"class":321},[170,884,885,887,889,891,893,895,897,899],{"class":172,"line":354},[170,886,357],{"class":299},[170,888,360],{"class":176},[170,890,363],{"class":180},[170,892,366],{"class":176},[170,894,369],{"class":198},[170,896,372],{"class":176},[170,898,300],{"class":194},[170,900,218],{"class":176},[170,902,903],{"class":172,"line":379},[170,904,188],{"emptyLinePlaceholder":187},[170,906,907],{"class":172,"line":384},[170,908,322],{"class":321},[170,910,911,913,915,917],{"class":172,"line":389},[170,912,328],{"class":321},[170,914,394],{"class":331},[170,916,398],{"class":397},[170,918,401],{"class":321},[170,920,921,923,925,927],{"class":172,"line":404},[170,922,328],{"class":321},[170,924,394],{"class":331},[170,926,369],{"class":397},[170,928,413],{"class":321},[170,930,931],{"class":172,"line":416},[170,932,351],{"class":321},[170,934,935,937,939,941,943,945,947,949,951,953,955],{"class":172,"line":421},[170,936,357],{"class":299},[170,938,426],{"class":299},[170,940,430],{"class":429},[170,942,433],{"class":176},[170,944,264],{"class":198},[170,946,360],{"class":176},[170,948,440],{"class":180},[170,950,443],{"class":176},[170,952,360],{"class":176},[170,954,448],{"class":180},[170,956,451],{"class":176},[170,958,959],{"class":172,"line":454},[170,960,457],{"class":176},[170,962,963,965,967,969,971,973,975,977,979,981,983],{"class":172,"line":460},[170,964,463],{"class":176},[170,966,448],{"class":180},[170,968,468],{"class":176},[170,970,471],{"class":429},[170,972,474],{"class":176},[170,974,477],{"class":429},[170,976,480],{"class":176},[170,978,440],{"class":180},[170,980,468],{"class":176},[170,982,471],{"class":429},[170,984,489],{"class":176},[170,986,987],{"class":172,"line":492},[170,988,495],{"class":176},[170,990,991],{"class":172,"line":498},[170,992,501],{"class":176},[503,994,996],{"id":995},"transactions","Transactions",[152,998,999],{},"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,1001,1002,1014],{},[513,1003,1004,1005,1007,1008,1010,1011,1013],{},"Setting ",[156,1006,521],{}," to ",[156,1009,525],{}," in ",[156,1012,517],{}," config file, which would affect all controllers",[513,1015,1016,1017,1019],{},"Overriding ",[156,1018,532],{}," method on any controller for a more granular control",[503,1021,1023],{"id":1022},"on-model-controllers","On Model Controllers",[538,1025,1026,1029,1032,1035,1038,1041,1044,1047,1050,1059,1066,1069,1072,1075,1078],{},[513,1027,1028],{},"beforeIndex - executed before retrieving the list of models.",[513,1030,1031],{},"afterIndex - executed after retrieving the list of models, but before building response.",[513,1033,1034],{},"beforeShow - executed before retrieving a model.",[513,1036,1037],{},"afterShow - executed after retrieving a model, but before building response.",[513,1039,1040],{},"beforeStore - executed before creating a new model instance and filling out attributes.",[513,1042,1043],{},"afterStore - executed after storing a model, but before building response.",[513,1045,1046],{},"beforeUpdate - executed before retrieving a model and filling out attributes.",[513,1048,1049],{},"afterUpdate - executed after updating a model, but before building response.",[513,1051,1052,1053,1055,1056,1058],{},"beforeSave - executed before the model is saved, but after ",[156,1054,569],{}," and ",[156,1057,573],{},".",[513,1060,1061,1062,1055,1064,1058],{},"afterSave - executed after the model is saved, but before ",[156,1063,580],{},[156,1065,583],{},[513,1067,1068],{},"beforeDestroy - executed before retrieving a model and deleting it.",[513,1070,1071],{},"afterDestroy - executed after deleting a model, but before building response.",[513,1073,1074],{},"beforeRestore - executed before retrieving a model and restoring it.",[513,1076,1077],{},"afterRestore - executed after restoring a model, but before building response.",[513,1079,1080,1081,1055,1083,1058],{},"beforeFresh - executed before the model is refreshed after saving, but before ",[156,1082,602],{},[156,1084,580],{},[152,1086,1087],{},[608,1088,1089],{},"Batch hooks:",[538,1091,1092,1095,1098,1101,1104,1107,1110,1113],{},[513,1093,1094],{},"beforeBatchStore - executed before creating new models.",[513,1096,1097],{},"afterBatchStore - executed after storing new models, but before building response.",[513,1099,1100],{},"beforeBatchUpdate - executed before retrieving models for updating.",[513,1102,1103],{},"afterBatchUpdate - executed after updating the models, but before building response.",[513,1105,1106],{},"beforeBatchDestroy - executed before retrieving models for deleting.",[513,1108,1109],{},"afterBatchDestroy - executed after deleting the models, but before building response.",[513,1111,1112],{},"beforeBatchRestore - executed before retrieving models for restoring.",[513,1114,1115],{},"afterBatchRestore - executed after restoring the models, but before building response.",[638,1117,1118],{},[152,1119,1120,1121,1123,1124,1126,1127,1055,1129,1131],{},"Related \"before\" and \"after\" hooks (e.g. ",[156,1122,569],{},", ",[156,1125,580],{},") as well as ",[156,1128,158],{},[156,1130,602],{}," are also executed for each model in batch operations.",[503,1133,1135],{"id":1134},"on-relationship-controllers","On Relationship Controllers",[152,1137,1138,1141],{},[608,1139,1140],{},"All types:"," relation controllers have before and after hooks for CRUD operations - same as model controllers.",[152,1143,1144],{},[608,1145,1146],{},"One-to-many:",[538,1148,1149,1152,1155,1158],{},[513,1150,1151],{},"beforeAssociate - executed after retrieving both models, but before associating a child model.",[513,1153,1154],{},"afterAssociate - executed after saving a relation model with associated child model id, but before building response.",[513,1156,1157],{},"beforeDissociate - executed after retrieving both models, but before dissociating a child model.",[513,1159,1160],{},"afterDissociate - executed after saving a relation model with associated child model id, but before building response.",[152,1162,1163],{},[608,1164,1165],{},"Many-to-many:",[538,1167,1168,1171,1174,1177,1180,1183,1186,1189,1192,1195],{},[513,1169,1170],{},"beforeSync - executed before retrieving a relation model.",[513,1172,1173],{},"afterSync - executed after syncing related models, but before building response.",[513,1175,1176],{},"beforeToggle - executed before retrieving a relation model.",[513,1178,1179],{},"afterToggle - executed after toggling related models, but before building response.",[513,1181,1182],{},"beforeAttach - executed before retrieving a relation model.",[513,1184,1185],{},"afterAttach - executed after attaching related model(s) to a relation model, but before building response.",[513,1187,1188],{},"beforeDetach - executed before retrieving a relation model.",[513,1190,1191],{},"afterDetach - executed after detaching related model(s) from a relation model, but before building response.",[513,1193,1194],{},"beforeUpdatePivot - executed before retrieving a relation model.",[513,1196,1197],{},"afterUpdatePivot - executed after updating pivot of related model, but before building response.",[720,1199,722],{},{"title":166,"searchDepth":173,"depth":184,"links":1201},[1202,1203,1204],{"id":995,"depth":184,"text":996},{"id":1022,"depth":184,"text":1023},{"id":1134,"depth":184,"text":1135},"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":1205},"1.guide\u002F05.hooks","PrWT-kj6nNzG8J83GkNT2he6n8nIhWpAjkXtmn9lBPs",1784394453116]