{"id":283,"date":"2023-01-21T20:24:26","date_gmt":"2023-01-21T17:24:26","guid":{"rendered":"https:\/\/akaunting.com\/hc\/?post_type=docs&#038;p=283"},"modified":"2023-01-21T20:27:33","modified_gmt":"2023-01-21T17:27:33","slug":"overriding-output","status":"publish","type":"docs","link":"https:\/\/akaunting.com\/hc\/docs\/developers\/overriding-output\/","title":{"rendered":"Overriding Output"},"content":{"rendered":"\n<p>Let\u2019s say you\u2019re developing a module\/app that adds\/removes functionality to\/from Akaunting core, and you want to override the output. However, to keep Akaunting up-to-date, you don\u2019t want to, and shouldn\u2019t, change\/hack the core files. As an example, let\u2019s see how to remove the&nbsp;<code>Phone<\/code>&nbsp;field from the customer creation form without changing the core files.<\/p>\n\n\n\n<p>First of all, create and install a&nbsp;<a href=\"https:\/\/akaunting.com\/hc\/docs\/developers\/modules\/\" target=\"_blank\" rel=\"noreferrer noopener\">module<\/a>.<\/p>\n\n\n\n<p>Then add the following code into the&nbsp;<code>boot<\/code>&nbsp;method of your&nbsp;<code>ServiceProvider<\/code>.&nbsp;<a href=\"https:\/\/laravel.com\/docs\/views#view-composers\" target=\"_blank\" rel=\"noreferrer noopener\">Here<\/a>&nbsp;you can learn more about view composers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">View::composer(\n    ['incomes.customers.create'], 'Modules\\MyBlog\\Http\\ViewComposers\\Customers'\n);<\/code><\/pre>\n\n\n\n<p>Then create the view composer file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\nnamespace Modules\\MyBlog\\Http\\ViewComposers;\n\nuse Illuminate\\View\\View;\n\nclass Customers\n{\n    public function compose(View $view): mixed\n    {\n        \/\/ Override just the 'content' section\n        $view-&gt;getFactory()-&gt;startSection('content', view('my-blog::customers.create'));\n\n        \/\/ Override the whole file\n        $view-&gt;setPath(view('my-blog::customers.create')-&gt;getPath());\n\n        \/\/ Push to a stack\n        $view-&gt;getFactory()-&gt;startPush('scripts', view('my-blog::script'));\n    }\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Finally, create a&nbsp;<a href=\"https:\/\/laravel.com\/docs\/blade\" target=\"_blank\" rel=\"noreferrer noopener\">Blade<\/a>&nbsp;template file&nbsp;<code>modules\/MyBlog\/Resources\/views\/customers\/create.blade.php<\/code>&nbsp;with your custom output. The original one is located in&nbsp;<code>resources\/views\/incomes\/customers\/create.blade.php<\/code>&nbsp;file.<\/p>\n\n\n\n<p>If you also want to modify the data stored in the database, you can create an Observer to\u00a0<a href=\"https:\/\/akaunting.com\/hc\/docs\/developers\/hooking-models\/\" target=\"_blank\" rel=\"noreferrer noopener\">hook models<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s say you\u2019re developing a module\/app that adds\/removes functionality to\/from Akaunting core, and you want to override the output. However, to keep Akaunting up-to-date, you don\u2019t want to, and shouldn\u2019t, change\/hack the core files. As an example, let\u2019s see how to remove the&nbsp;Phone&nbsp;field from the customer creation form without changing the core files. First of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":31,"menu_order":9,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-283","docs","type-docs","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/comments?post=283"}],"version-history":[{"count":3,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/283\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/283\/revisions\/288"}],"up":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/31"}],"wp:attachment":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/media?parent=283"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/doc_tag?post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}