PersonController.php 559 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace app\controllers;
  3. use app\models\Person;
  4. use yii\web\Controller;
  5. use yii\web\NotFoundHttpException;
  6. class PersonController extends \yii\web\Controller
  7. {
  8. public function actionIndex()
  9. {
  10. return $this->render('index');
  11. }
  12. public function actionPerson($person){
  13. $model = Person::findOne(['alias'=>$person]);
  14. if( ( !$model instanceof Person ) || $model->show == 'N' ){
  15. throw new NotFoundHttpException("Статья не найдена");
  16. }
  17. return $this->render("person",["model"=>$model]);
  18. }
  19. }