From 7c2d9680e08c60098d3a4c82b8a47cf0f049ae84 Mon Sep 17 00:00:00 2001 From: stes Date: Wed, 8 Nov 2017 17:14:30 +0200 Subject: [PATCH] event, blog, social --- controllers/ManageController.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+), 0 deletions(-) diff --git a/controllers/ManageController.php b/controllers/ManageController.php index 9dcc8d3..b4efc05 100755 --- a/controllers/ManageController.php +++ b/controllers/ManageController.php @@ -483,4 +483,43 @@ throw new NotFoundHttpException('The requested page does not exist.'); } } + + public function actionList($q = null, $id = null) + { + \Yii::$app->response->format = Response::FORMAT_JSON; + $out = [ + 'results' => [ + 'id' => '', + 'text' => '', + ], + ]; + if (!is_null($q)) { + $out[ 'results' ] = Product::find() + ->joinWith('lang') + ->select( + [ + 'product.id as id', + 'product_lang.title as text', + ] + ) + ->where( + [ + 'like', + 'product_lang.title', + $q, + ] + ) + ->andFilterWhere( + [ + '!=', + 'product.id', + $id, + ] + ) + ->limit(20) + ->asArray() + ->all(); + } + return $out; + } } -- libgit2 0.21.4