Commit 7c2d9680e08c60098d3a4c82b8a47cf0f049ae84

Authored by Anastasia
1 parent 79258b8f

event, blog, social

Showing 1 changed file with 39 additions and 0 deletions   Show diff stats
controllers/ManageController.php
@@ -483,4 +483,43 @@ @@ -483,4 +483,43 @@
483 throw new NotFoundHttpException('The requested page does not exist.'); 483 throw new NotFoundHttpException('The requested page does not exist.');
484 } 484 }
485 } 485 }
  486 +
  487 + public function actionList($q = null, $id = null)
  488 + {
  489 + \Yii::$app->response->format = Response::FORMAT_JSON;
  490 + $out = [
  491 + 'results' => [
  492 + 'id' => '',
  493 + 'text' => '',
  494 + ],
  495 + ];
  496 + if (!is_null($q)) {
  497 + $out[ 'results' ] = Product::find()
  498 + ->joinWith('lang')
  499 + ->select(
  500 + [
  501 + 'product.id as id',
  502 + 'product_lang.title as text',
  503 + ]
  504 + )
  505 + ->where(
  506 + [
  507 + 'like',
  508 + 'product_lang.title',
  509 + $q,
  510 + ]
  511 + )
  512 + ->andFilterWhere(
  513 + [
  514 + '!=',
  515 + 'product.id',
  516 + $id,
  517 + ]
  518 + )
  519 + ->limit(20)
  520 + ->asArray()
  521 + ->all();
  522 + }
  523 + return $out;
  524 + }
486 } 525 }