Initial import
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\parsed\Page;
|
||||
use app\services\Formatter;
|
||||
|
||||
/**
|
||||
* Class Pages
|
||||
* @package app\models
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $slug
|
||||
* @property $slug_en
|
||||
* @property $id
|
||||
* @property \app\models\Contacts $contacts
|
||||
*/
|
||||
class Pages extends _Base implements Page
|
||||
{
|
||||
|
||||
public function getContacts() {
|
||||
return $this->hasOne(Contacts::class, ['page_id' => 'id']);
|
||||
}
|
||||
public static function getList($id = null)
|
||||
{
|
||||
$pages = [];
|
||||
foreach (self::find()->all() as $page) {
|
||||
$pages[$page->id] = $page->name;
|
||||
}
|
||||
if ($id && !empty($pages[$id]))
|
||||
return $pages[$id];
|
||||
return $pages;
|
||||
}
|
||||
|
||||
|
||||
public function headerImage($rez = null)
|
||||
{
|
||||
return $this->getSrcOfSingleImage('header_page_image', $rez);
|
||||
}
|
||||
|
||||
public function headerTitle()
|
||||
{
|
||||
return \Yii::$app->language == 'en' ? $this->name_en : $this->name;
|
||||
}
|
||||
|
||||
public function text() {
|
||||
return \Yii::$app->language == 'en' ? $this->text_en : $this->text;
|
||||
}
|
||||
|
||||
public function getUrl() {
|
||||
return '/' . \Yii::$app->language . '/' . Formatter::cyrillicTrans($this->headerTitle()) . '/';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user