了解laravel / php中的方法

I am working on laravel/php in which I am checking how the method that is being used in the controller to return the view.

public function client($uuid) {


            $client = clients::with([
                'client_details' => function($q){

                    $q->with([
                        'client_ratings' => function($q){
                                $q->with(['rating_review',
                                    'rating_user' => function($q){
                                            $q->select('user_id','first_name','last_name');

                                        },
                                    'rating_user_media' => function($q) {
                                            $q->select('client_id','owner_id','url')->where('media_type','image')->where('context','user');
                                        }]);
                                $q->orderBy('created_at', 'desc');
                                $q->take(2);
                            }]);
                        },'owner_details','media','cancellation_policy'])->where('uuid',$uuid)->first();
            $groups = groups::getgroups(NULL);
            $data = [
                'groups' => $groups,
                'client' => $client
            ];

    //echo '<pre>';var_dump(json_decode(json_encode($data)));exit;
            return View::make('client',['data'=>$data]);
        }



Problem Statement:

The above php code is creating the JSON but I am not sure how is this JSON getting created.