How can i display multiple model data single action.

Hi, i can’t solve this problem in using rest api.

if action to X controller and display X model data is ok.

But if i have X and Y multiple model. Forexample single action to controller A,

How can i display X and Y model data in same json.

Note: i don’t ask expand or extraFields because i want to create json same hierarchy with two model and same property

Did you try to make a static function in class A, and call it in class B with qualified name A::function()?


To answer your question, below is example

Here i am accessing two models Movies and MoviesLikeDislike. Both methods are static and written inside Model class

$data['message'] = array(

                        'noofwatchingmembers'=> Movies::findMembersWatchingCount($movie['movie_code']),



echo json_encode($data, JSON_PRETTY_PRINT);