本文整理汇总了PHP中app\models\Student::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::findOne方法的具体用法?PHP Student::findOne怎么用?PHP Student::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Student
的用法示例。
在下文中一共展示了Student::findOne方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findModel
/**
* Finds the Student model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Student the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Student::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例2: actionUpdate
/**
* Updates an existing StudentPhone model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$studentId = $model->student_id;
$student = Student::findOne($studentId);
if (!user()->can('updateStudent', ['student' => $student])) {
setError('Access denied.');
return $this->redirect(['/student/view', 'id' => $studentId], 403);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['student' => $student, 'model' => $model]);
}
}
示例3: function
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="student-index">
<div class="well well-sm">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
</div>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['enrollment_id', ['attribute' => 'Nombre', 'value' => function ($dataProvider) {
$user = \app\models\User::findOne(['id' => $dataProvider->user_id]);
$person = \app\models\Person::findOne(['id' => $user->person_id]);
return $person->name . ' ' . $person->lastname;
}], ['attribute' => 'Licenciatura', 'value' => function ($dataProvider) {
$student = \app\models\Student::findOne(['user_id' => $dataProvider->user_id]);
$degree = \app\models\Degree::findOne(['id' => $student->degree_id]);
return $degree->name;
}], ['attribute' => 'Facultad', 'value' => function ($dataProvider) {
$faculty = \app\models\Faculty::findOne(['id' => $dataProvider->faculty_id]);
return $faculty->name;
}], 'current_semester', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['delete', 'user_id' => $model['user_id']], ['title' => Yii::t('app', 'Delete'), 'data-confirm' => Yii::t('app', '¿Estas seguro que deseas eliminar?'), 'data-method' => 'post']);
}]]]]);
?>
</div>
示例4:
<?php
/**
* Created by PhpStorm.
* User: David Cocom
* Date: 27/01/2016
* Time: 03:44 AM
*/
use app\models\Registration;
use app\models\Student;
use yii\bootstrap\Nav;
use yii\helpers\Url;
/*
*
• Cuenta
o Modificar cuenta
• Proyectos
o Búsqueda
• Avances
• Documentos
*/
$student = Student::findOne(['user_id' => Yii::$app->user->id]);
$registration = Registration::findOne(['student_id' => $student->id]);
$item = "";
if (isset($registration)) {
$item = $registration->beginning_date == null ? '<li data-toggle="modal" data-target="#modalChooseDate">
<a>Imprimir hoja de asignación</a>
</li>' : ['label' => 'Imprimir hoja de asignación', 'url' => Url::to(['/student/default/print-project-assignment-p-d-f'])];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left'], 'items' => [['label' => 'Cuenta', 'items' => [['label' => 'Modificar cuenta', 'url' => Url::to(['/person/update', 'id' => Yii::$app->user->id])]]], ['label' => 'Proyectos', 'items' => [['label' => 'Busqueda', 'url' => Url::to(['/project'])]]], ['label' => 'Avances', 'url' => Url::to(['/student/student-evidence'])], ['label' => 'Documentos', 'items' => [['label' => 'Imprimir hoja de preinscripción', 'url' => Url::to(['/student/default/print-preregistration-p-d-f'])], $item]]]]);
示例5: actionDelete
/**
* Deletes an existing Promotion model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$studentId = $model->student_id;
$student = Student::findOne($studentId);
if (!Yii::$app->user->can('updateStudent', ['student' => $student])) {
Yii::$app->session->setFlash('error', 'Access denied.');
return $this->redirect(['/student/index'], 403);
}
$model->delete();
return $this->redirect(['index', 'studentId' => $studentId]);
}
示例6: getUserRole
/**
* Figure it out the person role and returns an
* object of that type.
*/
public function getUserRole()
{
$rol = null;
if (Yii::$app->user->can('projectManager')) {
return $rol = ProjectManager::findOne(['user_id' => $this->id]);
}
if (Yii::$app->user->can('socialServiceManager')) {
return $rol = SocialServiceManager::findOne(['user_id' => $this->id]);
}
if (Yii::$app->user->can('student')) {
return $rol = Student::findOne(['user_id' => $this->id]);
}
return $rol;
}
示例7: setNotification
/**
* @param $studentId
* @param $task
* @param $studentEvidence
* @throws \yii\base\InvalidConfigException
*/
private function setNotification($studentId, $taskId, $proyectId, $description)
{
$notification = Yii::createObject(['class' => Notification::className(), 'user_id' => Student::findOne([$studentId])->user_id, 'description' => $description, 'role' => Notification::ROLE_STUDENT, 'created_at' => Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'), 'viewed' => false, 'url' => Url::to(['/student/student-evidence/view', 'task_id' => $taskId, 'project_id' => $proyectId, 'student_id' => $studentId])]);
$notification->save(false);
}
示例8: actionPrintEvidenceReport
/**
* @return mixed|\yii\web\Response
*/
public function actionPrintEvidenceReport()
{
$student = Student::findOne(['user_id' => Yii::$app->user->id]);
date_default_timezone_set("America/Mexico_City");
try {
$searchModel = new StudentEvidenceSearch();
$dataProviderAccepted = $searchModel->search(Yii::$app->request->queryParams, StudentEvidence::$ACCEPTED);
$registration = Registration::findOne(['student_id' => $student->id]);
$person = Person::findOne(User::findOne(Yii::$app->user->id)->person_id);
$project = Project::findOne($registration->project_id);
$projectM = ProjectManager::findOne($project->manager_id);
// get your HTML raw content without any layouts or scripts
$content = $this->render('studentEvidencePDF', ['registration' => $registration, 'student' => $student, 'person' => $person, 'project' => $project, 'projectM' => $projectM, 'searchModel' => $searchModel, 'dataProviderAccepted' => $dataProviderAccepted]);
$formatter = \Yii::$app->formatter;
// setup kartik\mpdf\Pdf component
$pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_LETTER, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Reporte de avances'], 'methods' => ['SetFooter' => ['Fecha de expedición: ' . $formatter->asDate(date('d-F-Y'))]]]);
// return the pdf output as per the destination setting
return $pdf->render();
} catch (InvalidConfigException $e) {
Yii::$app->getSession()->setFlash('danger', 'No tienes proyectos asignados');
return $this->redirect(Url::home());
}
}