Pass Value From One Controller Into Another

I have a test development which contains a number of tables (employee, personalDetails, address). My understanding of MVC leads me to see these almost as individual planets, where each (MVC) component plays a clearly defined role within that world.

I now want to pass requests for data and calculations between these worlds but I’m unsure as to how best go about it. An example would be … to return a view of employees who have take home salaries > $100,000 including bonuses ( e.g. employee controller asks personalDetails controller to calculate {goss salary + bonuses – tax} and return all appropriate instances, it then looks up and returns the relevant employees).

So do I create a function in personalDetails and call it from inside employee controller, or should this kind of thing go in an extension … or is there another approach?

Many thanks

Functions used by multiple controllers should be defined in master controller. (components/controller.php) or in another component. Then you can call it with $this->function().

Hope that helps.

Hi

you can also creates static function in Controller (component folder) and pass every you want. This function could returns the desired results and can be used from any controller that inherits this Controller