当前位置: 首页>>代码示例>>PHP>>正文


PHP Usuario::findOne方法代码示例

本文整理汇总了PHP中app\models\Usuario::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Usuario::findOne方法的具体用法?PHP Usuario::findOne怎么用?PHP Usuario::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Usuario的用法示例。


在下文中一共展示了Usuario::findOne方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: searchAluno

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchAluno($params)
 {
     $query = Monitoria::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         //return $dataProvider;
     }
     //Pega o id do usuario baseando-se no CPF do usuário logado
     $usuario = Usuario::findOne(['CPF' => Yii::$app->user->identity->cpf]);
     $query->joinWith(['usuario']);
     $query->joinWith(['disciplinaperiodo']);
     $query->joinWith(['periodoinscricao']);
     $query->leftJoin('disciplina', 'disciplina.id = disciplina_periodo.idDisciplina');
     $query->leftJoin('curso', 'curso.id = disciplina_periodo.idCurso');
     $query->andFilterWhere(['id' => $this->id, 'IDAluno' => $usuario->id]);
     $query->andFilterWhere(['like', 'usuario.name', $this->IDAluno]);
     $query->andFilterWhere(['like', 'disciplina.nomeDisciplina', $this->IDDisc]);
     $query->andFilterWhere(['like', 'curso.nome', $this->nomeCurso]);
     $query->andFilterWhere(['like', 'periodoinscricao.ano', $this->IDperiodoinscr]);
     $query->orderBy(['id' => SORT_DESC]);
     return $dataProvider;
 }
开发者ID:tammy00,项目名称:paps,代码行数:32,代码来源:MonitoriaSearch.php

示例2: actionPasswordupdate

 /**
  * 
  */
 public function actionPasswordupdate()
 {
     $modelo = new Usuario();
     if ($parametros = Yii::$app->request->post()) {
         if ($parametros['password'] == $parametros['repeat_password']) {
             $usuario = $modelo->findOne(['id' => $parametros['Usuario']['id']]);
             $usuario->setPassword($parametros['password']);
             $usuario->repeat_password = $parametros['repeat_password'];
             if ($usuario->update(false)) {
                 Yii::$app->session->setFlash('success', 'Usuario Editado con éxito!');
             } else {
                 $errores = $usuario->getErrors();
                 foreach ($usuario->getErrors() as $key => $value) {
                     for ($i = 0; $i < count($value); $i++) {
                         Yii::$app->session->setFlash('danger', 'El campo ' . $key . ' ' . $value[$i]);
                     }
                 }
             }
             Yii::$app->response->redirect(array('usuario/cambiarpassword', 'id' => $parametros['Usuario']['id']));
         } else {
             Yii::$app->session->setFlash('warning', 'Las contraseña deben ser iguales exactamente');
             Yii::$app->response->redirect(array('usuario/cambiarpassword', 'id' => $parametros['Usuario']['id']));
         }
     }
 }
开发者ID:jaimeirazabal1,项目名称:rnsii,代码行数:28,代码来源:UsuarioController.php

示例3: searchAluno

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchAluno($params)
 {
     $query = AlunoMonitoria::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     //Pega o id do usuario baseando-se no CPF do usuário logado
     $usuario = Usuario::findOne(['CPF' => Yii::$app->user->identity->cpf]);
     $query->andFilterWhere(['id' => $this->id, 'IDAluno' => $usuario->id]);
     $query->andFilterWhere(['like', 'aluno', $this->aluno]);
     $query->andFilterWhere(['like', 'matricula', $this->matricula]);
     $query->andFilterWhere(['like', 'cpf', $this->cpf]);
     $query->andFilterWhere(['like', 'codDisciplina', $this->codDisciplina]);
     $query->andFilterWhere(['like', 'nomeDisciplina', $this->nomeDisciplina]);
     $query->andFilterWhere(['like', 'codTurma', $this->codTurma]);
     $query->andFilterWhere(['like', 'professor', $this->professor]);
     $query->andFilterWhere(['like', 'nomeCurso', $this->nomeCurso]);
     $query->andFilterWhere(['like', 'bolsa_traducao', $this->bolsa_traducao]);
     $query->andFilterWhere(['like', 'status', $this->status]);
     $query->andFilterWhere(['like', 'periodo', $this->periodo]);
     $query->orderBy(['id' => SORT_DESC]);
     return $dataProvider;
 }
开发者ID:tammy00,项目名称:paps,代码行数:34,代码来源:AlunoMonitoriaSearch.php

示例4: findModel

 /**
  * Finds the Usuario model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Usuario the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Usuario::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:15,代码来源:UsuarioControllerGeneradoParaLaEntrega1.php

示例5: hasAccess

 /**
  * Finds user by password reset token
  *
  * @param  string      $token password reset token
  * @return static|null
  */
 public static function hasAccess($module, $controller = null, $action = null)
 {
     try {
         if (strcmp(strtoupper($module), "SIAP") == 0 && strcmp(strtoupper($controller), "DEFAULT") == 0 && strcmp(strtoupper($action), "INDEX") == 0) {
             return true;
         }
         if (\Yii::$app->user->isGuest) {
             return false;
         }
         $usuario = Usuario::findOne(\Yii::$app->user->identity->id);
         if ($usuario == null) {
             return false;
         }
         if ($usuario->isAdmin()) {
             return true;
         }
         if ($module == null) {
             return false;
         }
         $modulo = Modulo::findOne(['descripcion' => strtoupper($module)]);
         if ($controller == null) {
             if ($modulo) {
                 foreach ($usuario->idGrupos as $grupo) {
                     $grupo instanceof Grupo;
                     foreach ($grupo->idControladores as $controlador) {
                         $controlador instanceof Controlador;
                         if ($controlador->id_modulo == $modulo->id_modulo) {
                             return true;
                         }
                     }
                 }
             }
         } else {
             if ($action == null) {
                 $controlador = Controlador::findOne(['id_modulo' => $modulo->id_modulo, 'descripcion' => strtoupper($controller)]);
                 if ($modulo && $controlador) {
                     $controlador instanceof Controlador;
                     foreach ($usuario->idGrupos as $grupo) {
                         $grupo instanceof Grupo;
                         foreach ($grupo->idControladores as $controladorPermiso) {
                             if ($controlador->id_controlador == $controladorPermiso->id_controlador && $controlador->id_modulo == $modulo->id_modulo) {
                                 return true;
                             }
                         }
                     }
                 }
             } else {
                 $controlador = Controlador::findOne(['id_modulo' => $modulo->id_modulo, 'descripcion' => strtoupper($controller)]);
                 $accion = Acciones::findOne(['id_controlador' => $controlador->id_controlador, 'descripcion' => strtoupper($action)]);
                 if ($modulo && $controlador && $accion) {
                     $accion instanceof Acciones;
                     $controlador instanceof Controlador;
                     foreach ($usuario->idGrupos as $grupo) {
                         $grupo instanceof Grupo;
                         $permiso = AccionGrupo::findOne(['id_accion' => $accion->id_accion, 'id_controlador' => $controlador->id_controlador, 'id_grupo' => $grupo->id_grupo]);
                         if ($permiso) {
                             return true;
                         }
                     }
                 }
             }
         }
     } catch (Exception $ex) {
     }
     return false;
 }
开发者ID:aitanz,项目名称:BienesPublicos_,代码行数:72,代码来源:Usuario.php

示例6: findIdentity

 public static function findIdentity($id)
 {
     return Usuario::findOne(['Id' => $id]);
 }
开发者ID:rolion,项目名称:ventacompra,代码行数:4,代码来源:Usuario.php

示例7: actionGerarrelatoriosemestral

 public function actionGerarrelatoriosemestral($id)
 {
     $model = new Monitoria();
     $modelInfo = new ProfessorMonitoria();
     if ($model->load(Yii::$app->request->post())) {
         //Usuario - Pega professor baseando-se no CPF do usuário logado
         $professor = Usuario::findOne(['CPF' => Yii::$app->user->identity->cpf]);
         //Habilitar "extension=php_fileinfo.dll" em C:\xampp\php\php.ini
         $model->fileRelatorioSemestral = UploadedFile::getInstance($model, 'fileRelatorioSemestral');
         $arrayUpdate = ['pathArqRelatorioSemestral' => 'uploads/relatorio-semestral/' . $professor->cpf . '_' . date('Ydm_His') . '.' . $model->fileRelatorioSemestral->extension];
         Yii::$app->db->createCommand()->update('monitoria', $arrayUpdate, 'id=' . $id)->execute();
         $model->fileRelatorioSemestral->saveAs('uploads/relatorio-semestral/' . $professor->cpf . '_' . date('Ydm_His') . '.' . $model->fileRelatorioSemestral->extension);
         return $this->redirect(['professor']);
     } else {
         $model = $this->findModel($id);
         $modelInfo = ProfessorMonitoria::findOne(['id' => $id]);
         return $this->render('_form4', ['model' => $model, 'modelInfo' => $modelInfo]);
     }
 }
开发者ID:tammy00,项目名称:paps,代码行数:19,代码来源:MonitoriaController.php

示例8:

            <p><?php 
        echo Html::a('Disciplinas', ['/disciplina/index'], ['class' => 'btn btn-success']);
        ?>
</p>
            <p><?php 
        echo Html::a('Disciplinas para Monitoria', ['/disciplina-periodo/index'], ['class' => 'btn btn-success']);
        ?>
</p>
            <p><?php 
        echo Html::a('Comissão Avaliadora', ['/comissao/index'], ['class' => 'btn btn-success']);
        ?>
</p>

            <?php 
        //Pega professor baseando-se no CPF do usuário logado
        $professor = Usuario::findOne(['CPF' => Yii::$app->user->identity->cpf]);
        $comissao = Comissao::findOne(['idProfessor' => $professor->id]);
        if ($comissao != null && $comissao->idProfessor != null) {
            ?>
                <p> <?php 
            echo Html::a('Julgar Inscrições', ['avaliador'], ['class' => 'btn btn-success']);
            ?>
 </p>
            <?php 
        }
        ?>
            
            <p><?php 
        echo Html::a('Gerenciar Monitorias - Secretaria', ['secretaria'], ['class' => 'btn btn-success']);
        ?>
</p>
开发者ID:tammy00,项目名称:paps,代码行数:31,代码来源:index.php


注:本文中的app\models\Usuario::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。