<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "main_corp_user".
 *
 * @property integer $id
 * @property string $user_name
 * @property integer $main_corp_id
 * @property string $main_corp_name
 */
class MainCorpUser extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'main_corp_user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['main_corp_id'], 'integer'],
            [['user_name', 'main_corp_name'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'user_name' => 'User Name',
            'main_corp_id' => 'Main Corp ID',
            'main_corp_name' => 'Main Corp Name',
        ];
    }

    /**
     * Des:根据主体获取运营负责人列表
     * Name: getListForUserMianCorp
     * @author 倪宗锋
     */
    public function getListForUserMainCorp()
    {
        $where = [];
        $cookies = $_COOKIE;
        if (empty($cookies['user_main_corp'])== false && $cookies['user_main_corp'] != 1) {
            $where = ['=', 'main_corp_id', $cookies['user_main_corp']];
        }
        $list = self::find()->where($where)->asArray()->all();
        return $list;
    }
}
