public function actionIndex()
 {
     $modelform = new Restaurant();
     $results = new Restaurant();
     if ($modelform->load(Yii::$app->request->post())) {
         $connection = \Yii::$app->db;
         $results = $connection->createCommand("SELECT * FROM restaurants WHERE city LIKE '" . $modelform->city . "%' AND ((street LIKE '" . $modelform->street . "%') OR (name LIKE '" . $modelform->street . "%'))")->queryAll();
         //  $results = Restaurant::find()
         //     ->where(['city' => $model->city, 'street' =>$model->street ])
         //      ->all();
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->render('index', ['modelform' => $modelform, 'results' => $results]);
     } else {
         return $this->render('index', ['modelform' => $modelform, 'results' => $results]);
     }
 }
 /**
  * @return string
  */
 public function actionCreatepdf()
 {
     if (Yii::$app->user->isGuest || Yii::$app->user->identity->user_role != 4 && Yii::$app->user->identity->user_role != 3) {
         return $this->goHome();
     }
     $model = new Restaurant();
     if ($model->load(Yii::$app->request->post())) {
         $mpdf = new mPDF();
         $connection = \Yii::$app->db;
         $warehouses = $connection->createCommand('SELECT warehouse.description, warehouse.price, products.name FROM warehouse LEFT JOIN products ON warehouse.product_id=products.product_id WHERE warehouse.restaurant_id=' . $model->restaurant_id)->queryAll();
         $restaurant = Restaurant::find()->where(['restaurant_id' => $model->restaurant_id])->one();
         $mpdf->WriteHTML('<h1>Menu restauracji ' . $restaurant->name . ' ' . $restaurant->city . '</h1>');
         foreach ($warehouses as $warehouse) {
             $mpdf->WriteHTML($warehouse['name'] . '<br> Opis: ' . $warehouse['description'] . '<br>Cena: ' . $warehouse['price'] . '<br><br><br>');
         }
         $mpdf->Output();
         exit;
     }
     return $this->render('createpdf', ['model' => $model]);
 }