1
0
Fork 0
mirror of https://github.com/janickiy/yii2-nomer synced 2025-02-12 10:01:52 +00:00
yii2-nomer/controllers/GoogleController.php
2020-02-05 06:34:26 +03:00

32 lines
No EOL
970 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\controllers;
use app\models\SearchRequest;
use app\models\User;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
class GoogleController extends Controller {
public function actionIndex() {
$id = \Yii::$app->request->get("id");
$uuid = \Yii::$app->request->get("uuid");
$user = User::find()->where(["uuid" => $uuid])->one();
if(!$user) {
throw new BadRequestHttpException("Пользователь с uuid: ".$uuid." не найден");
}
$searchRequest = SearchRequest::getDb()->cache(function () use ($id, $user) {
return SearchRequest::find()->where(["id" => $id, "user_id" => $user->id])->one();
});
if(!$searchRequest) {
throw new BadRequestHttpException("Запрос с ID: ".$id." не найден");
}
return $this->render("index", [
"searchRequest" => $searchRequest
]);
}
}