Blame view

backend/controllers/CallController.php 1.3 KB
54f2fc2b   Alexey Boroda   first commit
1
2
3
4
  <?php
      
      namespace backend\controllers;
      
1ec8d36c   Alexey Boroda   -Searching applied
5
6
      use common\models\Call;
      use yii\data\ActiveDataProvider;
54f2fc2b   Alexey Boroda   first commit
7
8
9
10
11
      use yii\rest\ActiveController;
      
      class CallController extends ActiveController
      {
          public $modelClass = 'common\models\Call';
1ec8d36c   Alexey Boroda   -Searching applied
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
          
          public function actionSearch($word)
          {
              return new ActiveDataProvider(
                  [
                      'query' => Call::find()
                                     ->filterWhere(
                                         [
                                             'ilike',
                                             'company',
                                             trim($word),
                                         ]
                                     ),
                  ]
              );
          }
92e6e7c0   Alexey Boroda   -Logger attached
28
29
30
31
32
33
34
35
36
37
38
39
40
41
          
          public function afterAction($action, $result)
          {
              if ($action === 'create') {
                  $monologComponent = \Yii::$app->monolog;
                  $logger = $monologComponent->getLogger();
                  /**
                   * @var \Psr\Log\LoggerInterface $logger
                   */
                  $logger->info('Create action trigered, ip: ' . \Yii::$app->request->getRemoteIP());
              }
              
              return parent::afterAction($action, $result);
          }
54f2fc2b   Alexey Boroda   first commit
42
      }