Model
<?php
namespace app\models;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "social_network".
*
* @property int $id
* @property string $name
* @property string $slug
* @property int|null $parent_id
* @property string|null $type
*/
class SocialNetwork extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'social_network';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'slug'], 'required'],
[['name', 'slug', 'type'], 'string'],
[['parent_id'], 'integer'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'slug' => Yii::t('app', 'Slug'),
'parent_id' => Yii::t('app', 'Parent ID'),
'type' => Yii::t('app', 'Type'),
];
}
public static function getParentId($PARENT_ID)
{
return ArrayHelper::map(SocialNetwork::find()->where(['parent_id' => $PARENT_ID])->all(), 'id', 'name');
}
}
Public Last updated: 2020-06-10 05:02:23 AM