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


PHP Project::findOne方法代码示例

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


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

示例1: findModel

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

示例2: actionView

 public function actionView($id)
 {
     /** @var Project $projectModel */
     $projectModel = Project::findOne($id);
     if (!$projectModel) {
         throw new NotFoundHttpException('Project was not found');
     }
     /** @var Users[] $users */
     $users = $projectModel->users;
     return $this->render('view', ['model' => $projectModel, 'users' => $users]);
 }
开发者ID:CyanoFresh,项目名称:SelectPhoto,代码行数:11,代码来源:IndexController.php

示例3: actionStartDeploy

 /**
  * 发起上线
  *
  * @throws \Exception
  */
 public function actionStartDeploy()
 {
     $taskId = \Yii::$app->request->post('taskId');
     if (!$taskId) {
         static::renderJson([], -1, '任务号不能为空:)');
     }
     $this->task = Task::findOne($taskId);
     if (!$this->task) {
         throw new \Exception('任务号不存在:)');
     }
     if ($this->task->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的任务:)');
     }
     // 任务失败或者审核通过时可发起上线
     if (!in_array($this->task->status, [Task::STATUS_PASS, Task::STATUS_FAILED])) {
         throw new \Exception('任务不能被重复执行:)');
     }
     // 配置
     $this->conf = Project::getConf($this->task->project_id);
     // db配置
     $dbConf = Project::findOne($this->task->project_id);
     try {
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->_makeVersion();
             $this->_initWorkspace();
             $this->_gitUpdate();
             $this->_preDeploy();
             $this->_postDeploy();
             $this->_rsync();
             $this->_postRelease();
             $this->_link($this->task->link_id);
             $this->_cleanUp($this->task->link_id);
         } else {
             $this->_link($this->task->ex_link_id);
         }
         /** 至此已经发布版本到线上了,需要做一些记录工作 */
         // 记录此次上线的版本(软链号)和上线之前的版本
         ///对于回滚的任务不记录线上版本
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->task->ex_link_id = $dbConf->version;
         }
         $this->task->status = Task::STATUS_DONE;
         $this->task->save();
         // 记录当前线上版本(软链)回滚则是回滚的版本,上线为新版本
         $dbConf->version = $this->task->link_id;
         $dbConf->save();
     } catch (\Exception $e) {
         $this->task->status = Task::STATUS_FAILED;
         $this->task->save();
         // 清理本地部署空间
         $this->_cleanUp($this->task->link_id);
         throw $e;
     }
 }
开发者ID:royalwang,项目名称:walle-web,代码行数:59,代码来源:WalleController.php

示例4: actionCancelProject

 /**
  * @param $id
  * @throws NotFoundHttpException
  */
 public function actionCancelProject($id)
 {
     if (($model = Project::findOne($id)) !== null) {
         if ($model->approved == false) {
             //Se registra como cancelado
             $model->approved = false;
             $model->update(false);
             //Se envia el correo al estudiante
             Yii::$app->mailer->compose()->setFrom('from@domain.com')->setTo($model->projectManager->user->email)->setSubject('Proyecto' . ' ' . $model->name . ' rechazado.')->setTextBody('Su proyecto ha sido rechazado.')->setHtmlBody('<b>Su proyecto ha sido rechazado.</b>')->send();
             Yii::$app->getSession()->setFlash('success', 'El proyecto ha sido rechazado.');
             $this->redirect('view-projects');
         } else {
             Yii::$app->getSession()->setFlash('danger', 'El proyecto ya ha sido aprobado previamente.');
             $this->redirect('view-projects');
         }
     } else {
         throw new NotFoundHttpException('El proyecto no ha sido encontrado.');
     }
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:23,代码来源:ProjectController.php

示例5: actionView

 public function actionView($id)
 {
     $message = Message::findOne($id);
     $messages = Message::find()->where(['number' => $message->number])->all();
     $model = Project::findOne($message->project_id);
     $reply = new Message();
     foreach ($messages as $item) {
         $item->status = 4;
         $item->save();
     }
     if ($reply->load(Yii::$app->request->post()) && $reply->validate()) {
         // $reply->user_id =
         $reply->project_id = $message->project_id;
         $reply->status = 1;
         $reply->time = time();
         $reply->type = 'text';
         $reply->save();
         // Send twilio Text through project model
         $model->sendText([$message->user_id], $reply->message);
         Yii::$app->session->setFlash('success', 'Message Sent');
         $this->redirect(['/project/messages', 'id' => $message->project_id]);
     }
     return $this->render('view', ['message' => $message, 'messages' => $messages, 'model' => $model, 'reply' => $reply]);
 }
开发者ID:jcshep,项目名称:FrontRunner,代码行数:24,代码来源:MessageController.php

示例6: actionEditRelation

 /**
  * 项目审核管理员设置
  *
  * @return string
  * @throws \Exception
  */
 public function actionEditRelation($id, $type = 0)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception('关系不存在:)');
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的项目:)');
     }
     if (!in_array($type, [Group::TYPE_ADMIN, Group::TYPE_USER])) {
         throw new \Exception('未知的关系类型:)');
     }
     $group->type = (int) $type;
     if (!$group->save()) {
         throw new \Exception('更新失败');
     }
     $this->renderJson([]);
 }
开发者ID:richardfan,项目名称:walle-web,代码行数:25,代码来源:ConfController.php

示例7: StudentEvidenceSearch

<?php

use app\models\Project;
use app\models\Registration;
use app\models\student;
use app\models\StudentEvidenceSearch;
/* @var $this yii\web\View */
/* @var $searchModel app\models\StudentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Página principal';
Yii::$app->formatter->locale = 'es_ES';
$student = Student::findOne(['user_id' => Yii::$app->user->id]);
if ($registration = Registration::findOne(['student_id' => $student->id])) {
    $project = Project::findOne($registration->project_id);
    $textProject = 'Avances de proyecto: ' . $project->name;
    $searchModel = new StudentEvidenceSearch();
    $dataProviderNews = $searchModel->search(Yii::$app->request->queryParams, \app\models\StudentEvidence::$NEW);
    $dataProviderPending = $searchModel->search(Yii::$app->request->queryParams, \app\models\StudentEvidence::$PENDING);
    $countNews = $dataProviderNews->getTotalCount();
    $countPending = $dataProviderPending->getTotalCount();
    if ($countNews == 1) {
        $textDetails = 'Tienes ' . $countNews . ' avance nuevo.';
    } else {
        $textDetails = 'Tienes ' . $countNews . ' avances nuevos.';
    }
    if ($countPending == 1) {
        $textDetails .= '<br>Tienes ' . $countPending . ' avance pendiente.';
    } else {
        $textDetails .= '<br>Tienes ' . $countPending . ' avances pendientes.';
    }
    $textFooter = "<div class = 'panel-footer'><h4>Da click en el menú <i>Avances</i> para ver los detalles.</h4></div>";
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:31,代码来源:index.php

示例8: actionEditRelation

 /**
  * 项目审核管理员设置
  *
  * @return string
  * @throws \Exception
  */
 public function actionEditRelation($id, $type = 0)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception(yii::t('conf', 'relation not exists'));
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception(yii::t('w', 'you are not master of project'));
     }
     if (!in_array($type, [Group::TYPE_ADMIN, Group::TYPE_USER])) {
         throw new \Exception(yii::t('conf', 'unknown relation type'));
     }
     $group->type = (int) $type;
     if (!$group->save()) {
         throw new \Exception(yii::t('w', 'update failed'));
     }
     $this->renderJson([]);
 }
开发者ID:charlestang,项目名称:walle-web,代码行数:25,代码来源:ConfController.php

示例9: actionDelete

 public function actionDelete($id)
 {
     Project::findOne($id)->deleteRecursive();
     Yii::$app->getSession()->setFlash("success", 'The record was deleted.');
     return $this->redirect(["project/"]);
 }
开发者ID:JamesBarnsley,项目名称:Neptune,代码行数:6,代码来源:ProjectController.php

示例10: sendFollowersEmail

 /**
  * Sends an email with a link, for verifying the given email address.
  * @param integer $id
  * @return boolean whether the email was send
  */
 public function sendFollowersEmail($id)
 {
     $project = Project::findOne($id);
     $userIds = explode(',', $project->followers->usersFollowing);
     foreach ($userIds as $userId) {
         $user = User::findOne($userId);
         if ($user) {
             \Yii::$app->mailer->compose('emailFollower', ['user' => $user, 'project' => $project])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name])->setTo($user->email)->setSubject('Project update notification for ' . $project->name)->send();
         }
     }
 }
开发者ID:rhamlet1,项目名称:Hazid,代码行数:16,代码来源:ProjectController.php

示例11: actionDeleteRelation

 /**
  * 删除项目的用户关系
  *
  * @return string
  * @throws \Exception
  */
 public function actionDeleteRelation($id)
 {
     $group = Group::findOne($id);
     if (!$group) {
         throw new \Exception('关系不存在:)');
     }
     $project = Project::findOne($group->project_id);
     if ($project->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的项目:)');
     }
     if (!$group->delete()) {
         throw new \Exception('删除失败');
     }
     $this->renderJson([]);
 }
开发者ID:ZuoGuocai,项目名称:walle-web,代码行数:21,代码来源:ConfController.php

示例12: 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());
     }
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:26,代码来源:StudentEvidenceController.php

示例13:

?>
    </p>

    <div class="col-md-3">
        <ul class="nav nav-pills nav-stacked">
        <?php 
$projects = Project::find()->select(['projectID', 'name'])->all();
foreach ($projects as $project) {
    echo Html::tag('li', Html::a(Html::encode($project->name), ['index', 'id' => $project->projectID]), ['class' => $project->projectID == $model->selectedProjectID ? 'active' : '']);
}
?>
        </div>
    </div>
    <div class="col-md-9">
        <?php 
$project = Project::findOne($model->selectedProjectID);
if ($project) {
    $coordinator = User::findOne($project->coordinator);
    ?>
            <h1>
                <?php 
    echo Html::encode($project->name);
    ?>
                <div class="btn-toolbar pull-right">
                <?php 
    if (\Yii::$app->user->can('updateProjectStatus')) {
        echo Html::a('', ['update', 'id' => $project->projectID], ['class' => 'btn btn-default glyphicon glyphicon-pencil', 'title' => 'Update']);
    }
    if (\Yii::$app->user->can('deleteProject')) {
        echo Html::a('', ['delete', 'id' => $project->projectID], ['class' => 'btn btn-default glyphicon glyphicon-trash', 'title' => 'Delete', 'data-confirm' => 'Are you sure you want to delete this item?', 'data-method' => 'post', 'data-pjax' => '0']);
    }
开发者ID:rhamlet1,项目名称:Hazid,代码行数:31,代码来源:index.php


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