Your IP : 216.73.216.79


Current Path : /var/www/html/sprm/backend/models/
Upload File :
Current File : /var/www/html/sprm/backend/models/StaffAccess.php

<?php

namespace backend\models;

/**
 * This is the model class for table "ost_staff_access".
 *
 * @property integer $id
 * @property string $role_code
 * @property integer $staff_info_id
 */
class StaffAccess extends \yii\db\ActiveRecord 
{
    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'dmg_staff_access';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['staff_info_id'], 'integer'],
            [['role_code'], 'string', 'max' => 25],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'role_code' => yii::t('app', 'Role'),
            'staff_info_id' => yii::t('app', 'Staff Info ID'),
        ];
    }

    public static function getListStaffCourse() {
        $arr2 = [];

        $arr = self::find()->where(['role_code' => 'PKK'])->all();

        foreach ($arr as $user) {
            $arr2[$user->staff_info_id] = $user->staff->staff_name;
        }
        return $arr2;
    }

    public static function getStaffName($id) {
        $arr = self::find()->where(['staff_info_id' => $id])->one();
        return $arr->staff->staff_name;
    }

    public function getStaff()
    {
        return $this->hasOne(StaffDetail::className(), ['id' => 'staff_info_id']);
    }


}