/** * Validates the password. * This method serves as the inline validation for password. * * @param string $attribute the attribute currently being validated * @param array $params the additional name-value pairs given in the rule */ public function validatePassword($attribute, $params) { $user = \backend\models\Employee::findIdentity(Yii::$app->getUser()->getId()); if (!$user->validatePassword($this->old_password)) { $this->addError($attribute, Yii::t('app', 'Old password is incorrect')); } }
/** * Finds user by [[username]] * * @return Employee|null */ protected function getEmployee() { if ($this->_user === null) { $this->_user = Employee::findByUsername($this->username); } return $this->_user; }
/** * Creates data provider instance with search query applied * * @param string $searchQuery * * @return ActiveDataProvider */ public function search($searchQuery) { $query = Employee::find(); $query->where('status > 0'); if ($searchQuery !== null) { $query->andFilterWhere(['like', 'username', $searchQuery])->andFilterWhere(['like', 'email', $searchQuery])->andFilterWhere(['like', 'fullname', $searchQuery]); } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => false]); return $dataProvider; }
public function actionIndex($q = null) { $query = Employee::find(); $query->where(['status' => Employee::STATUS_ACTIVE]); if ($q != null) { $query->andFilterWhere(['like', 'username', $q]); $query->andFilterWhere(['like', 'fullname', $q]); $query->andFilterWhere(['like', 'email', $q]); } return $this->render('index', ['models' => $query->all()]); }
public function actionIndex($id = null) { Url::remember(); if ($id == null) { $myself = true; $model = Yii::$app->getUser()->getIdentity(); } else { $myself = false; $model = Employee::findIdentity($id); } return $this->render('index', ['model' => $model]); }
public function __construct($userId, $config = array()) { $this->user = Employee::findIdentity($userId); if ($this->user === null) { throw new \yii\web\NotFoundHttpException(Yii::t("app", "Not found employee with specify id")); } $this->allRoles['none'] = Yii::t('app', 'Not yet set role'); foreach (Yii::$app->getAuthManager()->getRoles() as $role) { $this->allRoles[$role->name] = ucfirst($role->name); } $roles = Yii::$app->getAuthManager()->getRolesByUser($userId); $this->roleName = count($roles) > 0 ? array_values($roles)[0]->name : 'none'; parent::__construct($config); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employee::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['emp_id' => $this->emp_id, 'basic_salary' => $this->basic_salary, 'tot_salary' => $this->tot_salary, 'bonus' => $this->bonus, 'rating' => $this->rating]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'nic', $this->nic])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'address_no', $this->address_no])->andFilterWhere(['like', 'address_street', $this->address_street])->andFilterWhere(['like', 'address_city', $this->address_city])->andFilterWhere(['like', 'mobile_no', $this->mobile_no])->andFilterWhere(['like', 'home_no', $this->home_no])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
<?php echo $model->attributeLabels()['email']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo $model->created_by == 0 ? "Console App" : Employee::findIdentity($model->created_by)->username; ?> </span> <?php echo $model->attributeLabels()['created_by']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo $model->created_by == 0 ? "Console App" : Employee::findIdentity($model->created_by)->username; ?> </span> <?php echo $model->attributeLabels()['updated_by']; ?> </li> <li class="list-group-item"> <span class="pull-right"> <?php echo date("d/m/Y h:i:s", $model->created_at); ?> </span> <?php echo $model->attributeLabels()['created_at']; ?> </li>
public function testTableName() { expect(Employee::tableName())->equals("employee"); }
public static function findByUsername($username) { return Employee::findOne(['username' => $username]); }
public function actionProd() { $employee = new Employee(['scenario' => 'create', 'fullname' => 'John Martin', 'username' => "johnm", 'email' => '*****@*****.**', 'phone' => '0986804874', 'password' => 'John1621993', 'confirm_password' => 'John1621993', 'gender' => Employee::MALE, 'created_by' => 0, 'updated_by' => 0, 'created_at' => time(), 'updated_at' => time()]); $employee->save(); $auth = \Yii::$app->getAuthManager(); }
/** * Finds the Employee model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Employee the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Employee::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function OrganisationAuthorized($code = [], $chairman = [0], $array_map = false) { $object_person = \backend\models\Person::find()->where(['id' => \backend\models\Employee::find()->select('person_id')->where(['organisation_id' => \backend\models\Organisation::find()->select('ID')->where(['KD_UNIT_ORG' => $code])->column(), 'chairman' => $chairman])->currentSatker()->column()])->active(); if ($array_map) { $data = ArrayHelper::map($object_person->asArray()->all(), 'id', 'name'); return $data; } else { $object_person->count(); return $object_person->count() > 0 ? true : false; } }