REST

Hi all.

I found that Yii2 has expand parameter for REST.

Does yii2 have parameter expand_limit?

For example if I want category expand to videos, but I need only 3 videos,

How I should call it?

url/categories?expand=videos&expand_limit=3 - does it true ?

Ok I did it




public function extraFields() 

    {

        return [

            'videos' => function ($model) {

                $videos_limit = \Yii::$app->request->get('videos_limit');

                $query = \Video::find()

                        ->where(['categorye_id' => $model->id]);

                if($videos_limit)

                    $query->limit($videos_limit);

                return $query->all();

            },

        ];

    }



Hello

if you use yii\rest\IndexAction Controller or an inerhit class use this

?per-page=5