本文整理汇总了PHP中app\models\Project::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::load方法的具体用法?PHP Project::load怎么用?PHP Project::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Project
的用法示例。
在下文中一共展示了Project::load方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post())) {
$model->status = R::PROJECT_CREATED;
$model->deadline = date('Y-m-d', strtotime($model->deadline));
$model->create_time = time();
$model->update_time = time();
$model->save();
if (isset($_POST['stage_name'])) {
$stage_name = $_POST['stage_name'];
$stage_description = $_POST['stage_description'];
$stage_deadline = $_POST['stage_deadline'];
$stage_who = $_POST['stage_who'];
foreach ($stage_name as $k => $v) {
$stage = new Stage();
$stage->name = $v;
$stage->description = $stage_description[$k];
$stage->deadline = strtotime($stage_deadline[$k]);
$stage->user_id = $stage_who[$k];
$stage->project_id = $model->id;
$stage->status = R::STAGE_CREATED;
$stage->create_time = time();
$stage->update_time = time();
$stage->save();
}
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例2: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: actionCreate
public function actionCreate()
{
$project = new Project();
if ($project->load(Yii::$app->request->post()) && $project->save()) {
Yii::$app->getSession()->setFlash("success", 'The record was saved.');
return $this->redirect(["project/"]);
}
return $this->render("create", ["models" => ["project" => $project]]);
}
示例4: actionCreate
public function actionCreate()
{
if (\Yii::$app->user->isGuest) {
throw new ForbiddenHttpException('Access denied');
}
$model = new Project();
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['/project/view', 'id' => $model->getPrimaryKey()]);
}
return $this->render('create', ['model' => $model]);
}
示例5: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
$user_id = User::find()->where("id=" . Yii::$app->user->id)->one()->id;
$manager_id = ProjectManager::find()->where("user_id=" . $user_id)->one()->id;
$model->manager_id = $manager_id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$vacancyValue = $_POST['Project']['vacancy'];
$newVacancy = new ProjectVacancy();
$newVacancy->project_id = $model->id;
$newVacancy->vacancy = $vacancyValue;
$newVacancy->save();
$degreesList = $_POST['Project']['degrees1'];
foreach ($degreesList as $value) {
$this->createStudentProfile($model->id, $value);
}
Yii::$app->getSession()->setFlash('success', 'El proyecto se ha creado exitosamente');
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: actionCopy
/**
* 复制项目配置
*
* @return string
* @throws \Exception
*/
public function actionCopy($projectId)
{
$project = $this->findModel($projectId);
// 复制为新项目
$project->name .= ' - copy';
$copy = new Project();
$copy->load($project->getAttributes(), '');
if (!$copy->save()) {
throw new \Exception(yii::t('conf', 'copy failed'));
}
// 删除ansible配置文件
if ($project->ansible) {
copy(Project::getAnsibleHostsFile($project->id), Project::getAnsibleHostsFile($copy->id));
}
$this->renderJson([]);
}
示例7: actionCopy
/**
* 复制项目配置
*
* @return string
* @throws \Exception
*/
public function actionCopy($projectId)
{
$project = $this->findModel($projectId);
// 复制为新项目
$project->name .= ' - copy';
$copy = new Project();
$copy->load($project->getAttributes(), '');
if (!$copy->save()) {
throw new \Exception(yii::t('conf', 'copy failed'));
}
$this->renderJson([]);
}
示例8: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'overview' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
$model->loadDefaultValues();
if ($model->load(Yii::$app->request->post())) {
$image = UploadedFile::getInstance($model, 'image');
if (!is_null($image)) {
// store the source file name
$model->logoname = $image->name;
$ext = end(explode(".", $image->name));
// generate a unique file name
$model->logo = Yii::$app->security->generateRandomString() . ".{$ext}";
$path = Yii::$app->basePath . '/web/uploads/' . $model->logo;
}
if ($model->save()) {
if (!is_null($image)) {
$image->saveAs($path);
}
$member = new Member();
$member->setAttribute('project_id', $model->id);
$member->setAttribute('user_id', Yii::$app->user->id);
$member->setAttribute('role', 'Administrator');
$member->save();
return $this->redirect(['overview', 'identifier' => $model->identifier]);
} else {
Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'Something went wrong and the settings was not saved.'));
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例9: actionCreate
/**
* Creates a new Project model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Project();
$model->scenario = 'create';
if ($model->load(Yii::$app->request->post()) && $model->save()) {
// Add Twilio Number
$model->addTwilioNumber();
Yii::$app->session->setFlash('success', 'Project successfully created');
return $this->redirect(['update', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}