[{"data":1,"prerenderedAt":1212},["ShallowReactive",2],{"navigation-ko":3,"navigation-v1":81,"\u002Fko\u002Fguide\u002Fhooks":146,"\u002Fko\u002Fguide\u002Fhooks-surround":736,"\u002Fko\u002Fguide\u002Fhooks-og":741},[4,55,77],{"title":5,"path":6,"stem":7,"children":8},"가이드","\u002Fko\u002Fguide","ko\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},"프롤로그","\u002Fko\u002Fguide\u002Fprologue","ko\u002F1.guide\u002F00.prologue",{"title":16,"path":17,"stem":18},"시작하기","\u002Fko\u002Fguide\u002Fgetting-started","ko\u002F1.guide\u002F02.getting-started",{"title":20,"path":21,"stem":22},"모델","\u002Fko\u002Fguide\u002Fmodels","ko\u002F1.guide\u002F03.models",{"title":24,"path":25,"stem":26},"연관관계","\u002Fko\u002Fguide\u002Frelationships","ko\u002F1.guide\u002F04.relationships",{"title":28,"path":29,"stem":30},"훅","\u002Fko\u002Fguide\u002Fhooks","ko\u002F1.guide\u002F05.hooks",{"title":32,"path":33,"stem":34},"검색","\u002Fko\u002Fguide\u002Fsearch","ko\u002F1.guide\u002F06.search",{"title":36,"path":37,"stem":38},"일괄 작업","\u002Fko\u002Fguide\u002Fbatch-operations","ko\u002F1.guide\u002F07.batch-operations",{"title":40,"path":41,"stem":42},"쿼리 파라미터","\u002Fko\u002Fguide\u002Fquery-parameters","ko\u002F1.guide\u002F08.query-parameters",{"title":44,"path":45,"stem":46},"보안","\u002Fko\u002Fguide\u002Fsecurity","ko\u002F1.guide\u002F09.security",{"title":48,"path":49,"stem":50},"응답","\u002Fko\u002Fguide\u002Fresponses","ko\u002F1.guide\u002F10.responses",{"title":52,"path":53,"stem":54},"명세","\u002Fko\u002Fguide\u002Fspecifications","ko\u002F1.guide\u002F11.specifications",{"title":56,"path":57,"stem":58,"children":59},"TypeScript SDK","\u002Fko\u002Ftypescript-sdk","ko\u002F2.typescript-sdk\u002F01.index",[60,61,64,68,71,74],{"title":10,"path":57,"stem":58},{"title":16,"path":62,"stem":63},"\u002Fko\u002Ftypescript-sdk\u002Fgetting-started","ko\u002F2.typescript-sdk\u002F02.getting-started",{"title":65,"path":66,"stem":67},"설정","\u002Fko\u002Ftypescript-sdk\u002Fconfiguration","ko\u002F2.typescript-sdk\u002F03.configuration",{"title":20,"path":69,"stem":70},"\u002Fko\u002Ftypescript-sdk\u002Fmodels","ko\u002F2.typescript-sdk\u002F04.models",{"title":24,"path":72,"stem":73},"\u002Fko\u002Ftypescript-sdk\u002Frelationships","ko\u002F2.typescript-sdk\u002F05.relationships",{"title":40,"path":75,"stem":76},"\u002Fko\u002Ftypescript-sdk\u002Fquery-parameters","ko\u002F2.typescript-sdk\u002F06.query-parameters",{"title":78,"path":79,"stem":80},"스크린캐스트","\u002Fko\u002Fscreencasts","ko\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":730,"extension":731,"links":732,"meta":733,"navigation":187,"path":29,"seo":734,"stem":30,"__hash__":735},"docs_ko\u002Fko\u002F1.guide\u002F05.hooks.md",{"type":149,"value":150,"toc":725},"minimark",[151,160,502,506,509,534,538,606,612,638,655,659,665,670,684,689,721],[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,537],{"id":536},"모델-컨트롤러의-훅","모델 컨트롤러의 훅",[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,646,652,654],{},"서로 연관된 \"before\" 및 \"after\" 훅(예: ",[156,645,570],{},", ",[156,648,581],{},")과 ",[156,651,158],{},[156,653,603],{},"는 일괄 작업에서도 각 모델마다 실행됩니다.",[503,656,658],{"id":657},"연관관계-컨트롤러의-훅","연관관계 컨트롤러의 훅",[152,660,661,664],{},[609,662,663],{},"모든 유형:"," 연관관계 컨트롤러에는 모델 컨트롤러와 동일하게 CRUD 작업을 위한 before 및 after 훅이 있습니다.",[152,666,667],{},[609,668,669],{},"일대다(One-to-many):",[539,671,672,675,678,681],{},[513,673,674],{},"beforeAssociate - 두 모델을 모두 조회한 후, 자식 모델을 연결하기 전에 실행됩니다.",[513,676,677],{},"afterAssociate - 연결된 자식 모델 ID와 함께 연관관계 모델을 저장한 후, 응답을 생성하기 전에 실행됩니다.",[513,679,680],{},"beforeDissociate - 두 모델을 모두 조회한 후, 자식 모델의 연결을 해제하기 전에 실행됩니다.",[513,682,683],{},"afterDissociate - 연결된 자식 모델 ID와 함께 연관관계 모델을 저장한 후, 응답을 생성하기 전에 실행됩니다.",[152,685,686],{},[609,687,688],{},"다대다(Many-to-many):",[539,690,691,694,697,700,703,706,709,712,715,718],{},[513,692,693],{},"beforeSync - 연관관계 모델을 조회하기 전에 실행됩니다.",[513,695,696],{},"afterSync - 연관된 모델들을 동기화한 후, 응답을 생성하기 전에 실행됩니다.",[513,698,699],{},"beforeToggle - 연관관계 모델을 조회하기 전에 실행됩니다.",[513,701,702],{},"afterToggle - 연관된 모델들을 토글한 후, 응답을 생성하기 전에 실행됩니다.",[513,704,705],{},"beforeAttach - 연관관계 모델을 조회하기 전에 실행됩니다.",[513,707,708],{},"afterAttach - 연관된 모델을 연관관계 모델에 연결(attach)한 후, 응답을 생성하기 전에 실행됩니다.",[513,710,711],{},"beforeDetach - 연관관계 모델을 조회하기 전에 실행됩니다.",[513,713,714],{},"afterDetach - 연관된 모델을 연관관계 모델에서 분리(detach)한 후, 응답을 생성하기 전에 실행됩니다.",[513,716,717],{},"beforeUpdatePivot - 연관관계 모델을 조회하기 전에 실행됩니다.",[513,719,720],{},"afterUpdatePivot - 연관된 모델의 피벗을 업데이트한 후, 응답을 생성하기 전에 실행됩니다.",[722,723,724],"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":726},[727,728,729],{"id":505,"depth":184,"text":505},{"id":536,"depth":184,"text":537},{"id":657,"depth":184,"text":658},"훅(Hooks)은 Orion의 강력한 기능 중 하나입니다. 메서드 자체를 오버라이드하지 않고도 특정 엔드포인트(또는 여러 엔드포인트) 내부의 흐름에 개입할 수 있습니다.","md",null,{},{"title":28,"description":730},"mHblLzmGmnK4aEvn5QJyIghTgfoHKiO5mZt770guGag",[737,739],{"title":24,"path":25,"stem":26,"description":738,"children":-1},"모델 연관관계를 API로 노출하는 방법을 알아봅니다.",{"title":32,"path":33,"stem":34,"description":740,"children":-1},"검색 수행, 필터 적용, 결과 정렬, 연관관계 포함, 데이터 집계 방법을 알아봅니다.",{"id":742,"title":102,"body":743,"description":1206,"extension":731,"links":732,"meta":1207,"navigation":187,"path":1208,"seo":1209,"stem":1210,"__hash__":1211},"docs_en\u002F1.guide\u002F05.hooks.md",{"type":149,"value":744,"toc":1201},[745,751,995,999,1002,1022,1026,1087,1092,1118,1133,1137,1143,1148,1162,1167,1199],[152,746,747,748,750],{},"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,749,158],{}," hook and associate a user with the post:",[161,752,753],{"className":163,"code":164,"language":165,"meta":166,"style":166},[156,754,755,761,765,785,789,805,825,845,849,859,863,867,881,885,903,907,911,921,931,935,959,963,987,991],{"__ignoreMap":166},[170,756,757,759],{"class":172,"line":173},[170,758,177],{"class":176},[170,760,181],{"class":180},[170,762,763],{"class":172,"line":184},[170,764,188],{"emptyLinePlaceholder":187},[170,766,767,769,771,773,775,777,779,781,783],{"class":172,"line":191},[170,768,195],{"class":194},[170,770,199],{"class":198},[170,772,202],{"class":176},[170,774,205],{"class":198},[170,776,202],{"class":176},[170,778,210],{"class":198},[170,780,202],{"class":176},[170,782,215],{"class":198},[170,784,218],{"class":176},[170,786,787],{"class":172,"line":221},[170,788,188],{"emptyLinePlaceholder":187},[170,790,791,793,795,797,799,801,803],{"class":172,"line":226},[170,792,229],{"class":194},[170,794,199],{"class":180},[170,796,202],{"class":176},[170,798,94],{"class":180},[170,800,202],{"class":176},[170,802,240],{"class":180},[170,804,218],{"class":176},[170,806,807,809,811,813,815,817,819,821,823],{"class":172,"line":245},[170,808,229],{"class":194},[170,810,250],{"class":180},[170,812,202],{"class":176},[170,814,205],{"class":180},[170,816,202],{"class":176},[170,818,259],{"class":180},[170,820,202],{"class":176},[170,822,264],{"class":180},[170,824,218],{"class":176},[170,826,827,829,831,833,835,837,839,841,843],{"class":172,"line":269},[170,828,229],{"class":194},[170,830,250],{"class":180},[170,832,202],{"class":176},[170,834,205],{"class":180},[170,836,202],{"class":176},[170,838,210],{"class":180},[170,840,202],{"class":176},[170,842,286],{"class":180},[170,844,218],{"class":176},[170,846,847],{"class":172,"line":291},[170,848,188],{"emptyLinePlaceholder":187},[170,850,851,853,855,857],{"class":172,"line":296},[170,852,300],{"class":299},[170,854,303],{"class":198},[170,856,306],{"class":299},[170,858,309],{"class":198},[170,860,861],{"class":172,"line":312},[170,862,315],{"class":176},[170,864,865],{"class":172,"line":318},[170,866,322],{"class":321},[170,868,869,871,873,875,877,879],{"class":172,"line":325},[170,870,328],{"class":321},[170,872,332],{"class":331},[170,874,335],{"class":331},[170,876,339],{"class":338},[170,878,342],{"class":331},[170,880,345],{"class":321},[170,882,883],{"class":172,"line":348},[170,884,351],{"class":321},[170,886,887,889,891,893,895,897,899,901],{"class":172,"line":354},[170,888,357],{"class":299},[170,890,360],{"class":176},[170,892,363],{"class":180},[170,894,366],{"class":176},[170,896,369],{"class":198},[170,898,372],{"class":176},[170,900,300],{"class":194},[170,902,218],{"class":176},[170,904,905],{"class":172,"line":379},[170,906,188],{"emptyLinePlaceholder":187},[170,908,909],{"class":172,"line":384},[170,910,322],{"class":321},[170,912,913,915,917,919],{"class":172,"line":389},[170,914,328],{"class":321},[170,916,394],{"class":331},[170,918,398],{"class":397},[170,920,401],{"class":321},[170,922,923,925,927,929],{"class":172,"line":404},[170,924,328],{"class":321},[170,926,394],{"class":331},[170,928,369],{"class":397},[170,930,413],{"class":321},[170,932,933],{"class":172,"line":416},[170,934,351],{"class":321},[170,936,937,939,941,943,945,947,949,951,953,955,957],{"class":172,"line":421},[170,938,357],{"class":299},[170,940,426],{"class":299},[170,942,430],{"class":429},[170,944,433],{"class":176},[170,946,264],{"class":198},[170,948,360],{"class":176},[170,950,440],{"class":180},[170,952,443],{"class":176},[170,954,360],{"class":176},[170,956,448],{"class":180},[170,958,451],{"class":176},[170,960,961],{"class":172,"line":454},[170,962,457],{"class":176},[170,964,965,967,969,971,973,975,977,979,981,983,985],{"class":172,"line":460},[170,966,463],{"class":176},[170,968,448],{"class":180},[170,970,468],{"class":176},[170,972,471],{"class":429},[170,974,474],{"class":176},[170,976,477],{"class":429},[170,978,480],{"class":176},[170,980,440],{"class":180},[170,982,468],{"class":176},[170,984,471],{"class":429},[170,986,489],{"class":176},[170,988,989],{"class":172,"line":492},[170,990,495],{"class":176},[170,992,993],{"class":172,"line":498},[170,994,501],{"class":176},[503,996,998],{"id":997},"transactions","Transactions",[152,1000,1001],{},"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,1003,1004,1016],{},[513,1005,1006,1007,1009,1010,1012,1013,1015],{},"Setting ",[156,1008,521],{}," to ",[156,1011,525],{}," in ",[156,1014,517],{}," config file, which would affect all controllers",[513,1017,1018,1019,1021],{},"Overriding ",[156,1020,532],{}," method on any controller for a more granular control",[503,1023,1025],{"id":1024},"on-model-controllers","On Model Controllers",[539,1027,1028,1031,1034,1037,1040,1043,1046,1049,1052,1061,1068,1071,1074,1077,1080],{},[513,1029,1030],{},"beforeIndex - executed before retrieving the list of models.",[513,1032,1033],{},"afterIndex - executed after retrieving the list of models, but before building response.",[513,1035,1036],{},"beforeShow - executed before retrieving a model.",[513,1038,1039],{},"afterShow - executed after retrieving a model, but before building response.",[513,1041,1042],{},"beforeStore - executed before creating a new model instance and filling out attributes.",[513,1044,1045],{},"afterStore - executed after storing a model, but before building response.",[513,1047,1048],{},"beforeUpdate - executed before retrieving a model and filling out attributes.",[513,1050,1051],{},"afterUpdate - executed after updating a model, but before building response.",[513,1053,1054,1055,1057,1058,1060],{},"beforeSave - executed before the model is saved, but after ",[156,1056,570],{}," and ",[156,1059,574],{},".",[513,1062,1063,1064,1057,1066,1060],{},"afterSave - executed after the model is saved, but before ",[156,1065,581],{},[156,1067,584],{},[513,1069,1070],{},"beforeDestroy - executed before retrieving a model and deleting it.",[513,1072,1073],{},"afterDestroy - executed after deleting a model, but before building response.",[513,1075,1076],{},"beforeRestore - executed before retrieving a model and restoring it.",[513,1078,1079],{},"afterRestore - executed after restoring a model, but before building response.",[513,1081,1082,1083,1057,1085,1060],{},"beforeFresh - executed before the model is refreshed after saving, but before ",[156,1084,603],{},[156,1086,581],{},[152,1088,1089],{},[609,1090,1091],{},"Batch hooks:",[539,1093,1094,1097,1100,1103,1106,1109,1112,1115],{},[513,1095,1096],{},"beforeBatchStore - executed before creating new models.",[513,1098,1099],{},"afterBatchStore - executed after storing new models, but before building response.",[513,1101,1102],{},"beforeBatchUpdate - executed before retrieving models for updating.",[513,1104,1105],{},"afterBatchUpdate - executed after updating the models, but before building response.",[513,1107,1108],{},"beforeBatchDestroy - executed before retrieving models for deleting.",[513,1110,1111],{},"afterBatchDestroy - executed after deleting the models, but before building response.",[513,1113,1114],{},"beforeBatchRestore - executed before retrieving models for restoring.",[513,1116,1117],{},"afterBatchRestore - executed after restoring the models, but before building response.",[639,1119,1120],{},[152,1121,1122,1123,646,1125,1127,1128,1057,1130,1132],{},"Related \"before\" and \"after\" hooks (e.g. ",[156,1124,570],{},[156,1126,581],{},") as well as ",[156,1129,158],{},[156,1131,603],{}," are also executed for each model in batch operations.",[503,1134,1136],{"id":1135},"on-relationship-controllers","On Relationship Controllers",[152,1138,1139,1142],{},[609,1140,1141],{},"All types:"," relation controllers have before and after hooks for CRUD operations - same as model controllers.",[152,1144,1145],{},[609,1146,1147],{},"One-to-many:",[539,1149,1150,1153,1156,1159],{},[513,1151,1152],{},"beforeAssociate - executed after retrieving both models, but before associating a child model.",[513,1154,1155],{},"afterAssociate - executed after saving a relation model with associated child model id, but before building response.",[513,1157,1158],{},"beforeDissociate - executed after retrieving both models, but before dissociating a child model.",[513,1160,1161],{},"afterDissociate - executed after saving a relation model with associated child model id, but before building response.",[152,1163,1164],{},[609,1165,1166],{},"Many-to-many:",[539,1168,1169,1172,1175,1178,1181,1184,1187,1190,1193,1196],{},[513,1170,1171],{},"beforeSync - executed before retrieving a relation model.",[513,1173,1174],{},"afterSync - executed after syncing related models, but before building response.",[513,1176,1177],{},"beforeToggle - executed before retrieving a relation model.",[513,1179,1180],{},"afterToggle - executed after toggling related models, but before building response.",[513,1182,1183],{},"beforeAttach - executed before retrieving a relation model.",[513,1185,1186],{},"afterAttach - executed after attaching related model(s) to a relation model, but before building response.",[513,1188,1189],{},"beforeDetach - executed before retrieving a relation model.",[513,1191,1192],{},"afterDetach - executed after detaching related model(s) from a relation model, but before building response.",[513,1194,1195],{},"beforeUpdatePivot - executed before retrieving a relation model.",[513,1197,1198],{},"afterUpdatePivot - executed after updating pivot of related model, but before building response.",[722,1200,724],{},{"title":166,"searchDepth":173,"depth":184,"links":1202},[1203,1204,1205],{"id":997,"depth":184,"text":998},{"id":1024,"depth":184,"text":1025},{"id":1135,"depth":184,"text":1136},"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":1206},"1.guide\u002F05.hooks","PrWT-kj6nNzG8J83GkNT2he6n8nIhWpAjkXtmn9lBPs",1784394459151]