AuthorController.php 642 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace app\controllers;
  3. use app\models\Authors;
  4. use yii\web\Controller;
  5. use yii\web\NotFoundHttpException;
  6. class AuthorController extends \yii\web\Controller
  7. {
  8. public function actionIndex()
  9. {
  10. return $this->render('index');
  11. }
  12. public function actionView($author){
  13. if( is_numeric($author) ){
  14. $model = Authors::findOne(['id'=>$author]);
  15. }else{
  16. $model = Authors::findOne(['url'=>$author]);
  17. }
  18. if( ( !$model instanceof Authors ) || $model->show == 0 ){
  19. throw new NotFoundHttpException("Автор не найден");
  20. }
  21. return $this->render("person",["model"=>$model]);
  22. }
  23. }