File: /home/safarimaris/home/safarimaris/frontend/controllers/SightsController.php
<?php
namespace frontend\controllers;
use Yii;
use common\models\Site;
use yii\web\NotFoundHttpException;
class SightsController extends Controller
{
public function actionIndex()
{
if (($list = Site::find()->all()) !== null) {
return $this->render('index', [
'list' => $list,
]);
} else {
throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
}
return $this->render('index');
}
public function actionShow($url)
{
Yii::$app->redirect->site(); //redirect old urls
if (($model = Site::find()->where(['url' => $url])->one()) !== null) {
$this->view->params['bg'] = '<div class="pbg-bot"></div>';
$this->view->params['bodyClass'] = 'boat-page';
$this->view->params['ogImage'] = $model->ogImage;
return $this->render('show', [
'model' => $model,
]);
} else {
throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
}
}
}