| Current Path : /var/www/html/dosmv2/backend/models/i18n/ |
| Current File : /var/www/html/dosmv2/backend/models/i18n/DmgI18nMessage.php |
<?php
namespace backend\models\i18n;
use Yii;
/**
* This is the model class for table "dmg_i18n_message".
*
* @property integer $id
* @property string $language
* @property string $translation
*
* @property DmgI18nSourceMessage $id0
*/
class DmgI18nMessage extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [];
}
/**
*
* @inheritdoc
*/
public static function tableName()
{
return 'dmg_i18n_message';
}
public $category = [
"app" => "App",
"portal" => "Portal",
"system" => "System",
"yii" => "Default Yii"
];
public $position = [
"Badge",
"BreadCrumb",
"Paragraph",
"Text",
"Title",
"Header",
"Icon",
"Label",
"Jumbotron",
"Content",
"Table Head",
"Button",
"Quote",
"Alert",
"Input Hint",
"Others",
"Dropdown",
"Modal",
"Navbar",
"Sidebar",
"Toast",
"Tooltip"
];
public function position()
{
$position = [];
array_walk($this->position, function ($arr) use (&$position) {
$position[$arr] = $arr;
});
ksort($position);
return $position;
}
/**
* Language Code
*
* @var array
*/
public static $languages = [
'Malay' => [
"label" => 'Bahasa Melayu',
"flag" => "Malaysia"
],
'English' => [
"label" => 'English',
"flag" => "United-Kingdom"
]
// 'ar' => ["label" => 'Ar - Arabic',"flag"=>"Saudi-Arabia"],
// 'in' => ["label" => 'In - Indonesia',"flag"=>"Indonesia"],
// 'ch' => ["label" => 'Ch - Chinesse',"flag"=>"China"],
// 'ta' => ["label" => 'Ta - Tamil',"flag"=>"India"],
];
/**
*
* @inheritdoc
*/
public function rules()
{
return [
[
[
'id',
'language','translation'
],
'required'
],
[['translation'],'unique'],
[
[
'id'
],
'integer'
],
[
[
'language',
'translation'
],
'string'
],
[
[
'id'
],
'exist',
'skipOnError' => true,
'targetClass' => DmgI18nSourceMessage::className(),
'targetAttribute' => [
'id' => 'id'
]
]
];
}
/**
*
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'language' => Yii::t('app', 'Language'),
'position' => Yii::t('app', 'Type'),
'translation' => Yii::t('app', 'Translation')
];
}
/**
*
* @return \yii\db\ActiveQuery
*/
public function getId0()
{
return $this->hasOne(DmgI18nSourceMessage::className(), [
'id' => 'id'
]);
}
public static function translationByid($id)
{
return self::find()->select('language,translation')
->where([
'id' => $id
])
->asArray()
->all();
}
}