News.php 458 B

12345678910111213141516171819202122
  1. <?php
  2. namespace app\models;
  3. use app\helpers\Transliterator;
  4. use yii\helpers\Inflector;
  5. /**
  6. * @property string $url
  7. */
  8. class News extends \app\models\base\News
  9. {
  10. public function getUrl():string
  11. {
  12. if(count($this->topics)>0){
  13. $topic = Transliterator::toUrl($this->topics[0]->title)."/";
  14. } else{
  15. $topic = "";
  16. }
  17. return "/news/".$topic.Transliterator::toUrl($this->title)."-".$this->id;
  18. }
  19. }