Seo.php
607 Bytes
<?php
namespace frontend\components;
use common\models\SeoSearch;
use yii\base\Widget;
class Seo extends Widget
{
private $url;
public $row;
public function init(){
$this->url = $_SERVER['REQUEST_URI'];
parent::init();
}
public function run()
{
$widgetData = $this->findModel();
return $widgetData->{$this->row};
}
protected function findModel()
{
if (($model = \common\models\Seo::findOne(['url'=>$this->url])) !== null) {
return $model;
} else {
return new SeoSearch();
}
}
}