public function register(Request $request) { $job = new Job(); $job->timestamps = false; $job->jobTitle = $request->input('title'); $job->jobAttributes = $request->input('attributes'); $job->jobDescription = $request->input('description'); $job->jobPublishDate = $request->input("finishDate"); $job->jobFinishDate = $request->input('finishDate'); $job->jobLocation = $request->input('location'); $job->jobNeedPersonal = $request->input('needPersonal'); $job->jobSector = $request->input('sector'); $job->jobPozisyonTip = $request->input('pozisyonTip'); $job->jobDepartment = $request->input('department'); $job->jobLevel = $request->input('level'); $job->jobExperienceLevel = $request->input('experienceLevel'); $job->jobEducationLevel = $request->input('educationLevel'); if ($job->save()) { //Session::set('employeeId', $query->employeeId); $result = array("result" => "success"); } else { $result = array("result" => "failed"); } return \View::make('ajaxResult', $result); }
function refreshComment($id) { $job = new Job(); $job->type = 'refresh_comment'; $job->arguments = json_encode(['id' => $id]); $job->save(); }
/** * Creates a new Job model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Job(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
private function failJob(Job $job, $msg) { $message = "Job with ID {$job->id} failed: {$msg}"; echo "{$message}\n"; Yii::getLogger()->log($message, Logger::LEVEL_ERROR); $job->status = 'failed'; if (!$job->save()) { Yii::getLogger()->log("Failed to save failure status in the job {$job->id}", Logger::LEVEL_ERROR); } }
/** * RESTful Method for creating jobs * * @return json */ public function store() { $payload['success'] = false; $job = new Job(); foreach (\Input::all() as $key => $value) { $job->{$key} = $value; } $output = $job->save(); if (false !== $output) { $payload['success'] = true; $payload['contents'] = ['id' => $job->id]; } return response()->json($payload); }
/** * Creates a new Job model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $admin_id = Yii::$app->user->identity->id; $model = new Job(); // $companies = Company::findBySql('SELECT * FROM wolf_company order by company_name')->all(); // $companies = Company::find()->all(); $companies = Company::find(); if (Yii::$app->user->identity->type == 'normal') { $companies = $companies->innerJoin('wolf_admin_to_company wc', 'wc.company_id=wolf_company.company_id'); $companies = $companies->where('admin_id=' . $admin_id); } $companies = $companies->orderBy('company_name'); $companies = $companies->asArray(); $companies = $companies->all(); // echo $companies->createCommand()->getRawSql();exit; if ($model->load(Yii::$app->request->post())) { $time_in_hour = $_POST['Job']['time_in_hour']; $time_in_minute = $_POST['Job']['time_in_minute']; $time_out_hour = $_POST['Job']['time_out_hour']; $time_out_minute = $_POST['Job']['time_out_minute']; $model->time_in = $time_in_hour . ':' . $time_in_minute . ':00'; $model->time_out = $time_out_hour . ':' . $time_out_minute . ':00'; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->job_id]); } else { return $this->render('create', ['model' => $model, 'companies' => $companies]); } }
/** * Updates an existing Person model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $jobModel = $model->job; if ($jobModel->load(Yii::$app->request->post()) && $jobModel->validate() && $model->load(Yii::$app->request->post()) && $model->validate()) { $transaction = $model->getDb()->beginTransaction(); try { if (is_numeric($jobModel->name)) { $jobModel = $jobModel->findOne($jobModel->name); } else { $jobModel = new Job(); $jobModel->load(Yii::$app->request->post()); if (!$jobModel->save(false)) { throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($jobModel->tableName())), 'msj' => print_r($jobModel->getErrors(), true)]), 500); } } if ($model->job_id != $jobModel->id) { $model->job_id = $jobModel->id; } if (!$model->save(false)) { throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($model->tableName())), 'msj' => print_r($model->getErrors(), true)]), 500); } $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model, 'jobModel' => $jobModel]); } }