Set Params To $Searchmodel->Search

Hi friends, what is the best practice for seting params of $searchModel->search();

$searchModel->search($_GET, $id);


$searchModel->search(array_merge($_GET, ['id' => $id]);

  1. $_GET is better to be accessed as Yii::$app->request->get().

  2. There’s no second parameter in search() so your #2 seems to be more appropriate.

Yes, but I have to do $params[‘id’] in public function search($params) { … ] in models. Аnd it’ll not go wrong if you submit alongside $searchModel->search(array_merge($_GET, [‘id’ => $id]);