本文整理汇总了PHP中app\models\Task::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::save方法的具体用法?PHP Task::save怎么用?PHP Task::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->getAjaxResponse();
}
}
示例2: actionCreate
public function actionCreate()
{
$task = new Task();
if ($task->load(Yii::$app->request->post()) && $task->save()) {
Yii::$app->getSession()->setFlash("success", 'The record was saved.');
return $this->redirect(["task/"]);
}
return $this->render("create", ["models" => ["task" => $task]]);
}
示例3: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed test
*/
public function actionCreate()
{
$model = new Task();
$categories = Category::find()->all();
$units = DicUnit::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'categories' => $categories, 'units' => $units]);
}
}
示例5: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
$modelDevice = new Device();
$modelAction = new Action();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'from_device_ids' => ArrayHelper::map($modelDevice->getDeviceMaster(), 'id', 'name'), 'to_device_ids' => ArrayHelper::map($modelDevice->getDeviceAll(), 'id', 'name'), 'action_ids' => ArrayHelper::map($modelAction->getActionAll(), 'id', 'name')]);
}
}
示例6: actionNew
/**
* Добавление нового задания в таблицу
* @param string $title Название задания
* @return redirect
*/
public function actionNew($title)
{
SiteController::locale();
$task = new Task();
$task->title = $title;
$task->status = Task::STATUS_ACTIVE;
$task->date = date('Y-m-d H:i:s');
if ($task->save()) {
Yii::$app->session->setFlash('success', Yii::t('msg/msg', 'Запись добавлена'));
} else {
Yii::$app->session->setFlash('errors', $task->errors);
}
return $this->redirect("/");
}
示例7: store
/**
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function store(Request $request)
{
$task = new Task();
$task->title = $request->title;
$task->description = $request->description;
$task->is_complete = 0;
$task->completed_at = null;
if ($task->save()) {
$response = ['code' => 200, 'message' => 'OK', 'data' => $task];
return response()->json($response, $response['code'])->header('Location', $request->root() . '/api/tasks/' . $task->id);
} else {
//TODO
}
}
示例8: store
public function store(TaskRequest $request)
{
$task = new Task();
$task->name_en = $request->input('name_en');
$task->name_bn = $request->input('name_bn');
$task->component_id = $request->input('component_id');
$task->module_id = $request->input('module_id');
$task->route = $request->input('route');
$task->icon = $request->input('icon');
$task->description = $request->input('description');
$task->ordering = $request->input('ordering');
$task->created_by = Auth::user()->id;
$task->created_at = time();
$task->save();
Session()->flash('flash_message', 'Task has been created!');
return redirect('tasks');
}
示例9: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
* @throws UserException
*/
public function actionCreate()
{
$goalId = (int) Yii::$app->request->get('goal_id', 0);
if (!$goalId) {
throw new UserException('Goal id is not provided');
}
$goal = Goal::findOne($goalId);
if (!$goal) {
throw new UserException("Goal [{$goalId}] not found");
}
$model = new Task(['goal_id' => $goalId]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Yii::$app->request->post('referrer') ?: $model->goal->urlTaskList());
} else {
return $this->render('create', ['model' => $model]);
}
}
示例10: afterSave
public function afterSave($insert, $changed)
{
if ($insert) {
foreach (WorkflowTask::findAll(['workflow_id' => $this->workflow_id]) as $orig) {
$task = new Task();
$skips = ['workflow_task_id', 'workflow_id', 'regist_date', 'update_date'];
foreach (Task::getTableSchema()->columnNames as $cols) {
if (in_array($cols, $skips)) {
continue;
}
$task->{$cols} = $orig->{$cols};
}
$task->user_id = Yii::$app->user->id;
$task->project_id = $this->project_id;
$task->save();
}
}
parent::afterSave($insert, $changed);
}
示例11: execute
public static function execute($id)
{
$model = TaskDefined::findOne($id);
$modelTask = new Task();
$modelTask->from_device_id = $model->from_device_id;
$modelTask->to_device_id = $model->to_device_id;
$modelTask->action_id = $model->action_id;
if (!$modelTask->save()) {
print_r($modelTask->errors);
return false;
}
// check for a error in the data
foreach (['error:', 'err:'] as $needle) {
if (false !== strpos($modelTask->data, $needle)) {
return false;
}
}
return true;
}
示例12: actionUpdate
/**
* Updates an existing Task model.
* If update is successful, the browser will be redirected to the 'update' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id = null, $partner_id = null)
{
if ($id) {
$model = $this->findModel($id);
} else {
$model = new Task();
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
return $this->redirect(['index']);
} else {
if (!$id) {
$model->timestamp = Yii::$app->formatter->asDate(time());
$model->user_id = Yii::$app->user->id;
if ($partner_id) {
$model->select_partner = Partner::findOne($partner_id);
}
}
return $this->renderAjax('update', ['model' => $model]);
}
}
示例13: actionTasks
/**
*
*/
public function actionTasks()
{
$user = User::findOne(['username' => 'admin']);
if (!$user) {
throw new \Exception('Admin user not exists.');
}
\Yii::$app->db->createCommand('TRUNCATE task; TRUNCATE user_task;')->execute();
$taskList = [['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(8), 'description' => 'some description', 'timeStart' => time() - 60 * 60 * 24 * 7, 'timeEnd' => time() + 60 * 60 * 24 * 7], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(6), 'description' => 'some description', 'timeStart' => time() - 60 * 60 * 5, 'timeEnd' => time() + 60 * 60 * 5], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(4), 'description' => 'some description', 'timeStart' => time() + 60 * 60 * 2, 'timeEnd' => time() + 60 * 60 * 24], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(7), 'description' => 'some description', 'timeStart' => time() + 60 * 60 * 24 * 1, 'timeEnd' => time() + 60 * 60 * 24 * 7]];
$tasks = null;
foreach ($taskList as $taskEntry) {
$task = new Task();
$task->userID = $taskEntry['userID'];
$task->title = $taskEntry['title'];
$task->description = $taskEntry['description'];
$task->timeStart = $taskEntry['timeStart'];
$task->timeEnd = $taskEntry['timeEnd'];
$task->timeCreated = time();
$task->save();
$tasks[] = $task;
}
$this->assignRandom($tasks);
}
示例14: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @param integer $projectId
* @return mixed
*/
public function actionCreate($projectId)
{
$model = new Task();
if ($model->load(Yii::$app->request->post())) {
if (strtotime($model->delivery_date) >= strtotime(Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'))) {
$students = $_POST['Task']['students'];
$model->status = Task::NEW_TASK;
$model->project_id = $projectId;
$model->save();
foreach ($students as $value) {
Yii::$app->db->createCommand()->insert('student_evidence', ['task_id' => $model->id, 'project_id' => $model->project_id, 'evidence_id' => null, 'student_id' => $value, 'status' => Task::NEW_TASK])->execute();
$this->setNotification($value, $model->id, $model->project_id, Notification::NEW_TASK);
}
Yii::$app->getSession()->setFlash('success', 'Petición creada exitosamente');
return $this->redirect(['student-evidence/index']);
} else {
Yii::$app->getSession()->setFlash('danger', 'La fecha de entrega no puede ser anterior a la fecha actual');
return $this->render('create', ['model' => $model, 'projectId' => $projectId]);
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例15: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (($role = priviledge::getRole()) == 'Admin') {
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->url = strtolower($model->url);
$model->status = 'Pending';
//$model->user_id = \Yii::$app->user->identity;
$mode = new LoginForm();
$mode->username = \Yii::$app->user->identity->username;
$user = new User();
if ($user = $mode->getUser()) {
$model->user_id = $user->id;
}
$listsocmed = $_POST['Task']['socmed'];
$model->facebook = 'No';
$model->twitter = 'No';
foreach ($listsocmed as $value) {
if ($value == 'Facebook') {
$model->facebook = 'Yes';
}
if ($value == 'Twitter') {
$model->twitter = 'Yes';
}
}
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->task_id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
return $this->render('create', ['model' => $model]);
}
} else {
throw new ForbiddenHttpException();
}
}