本文整理汇总了PHP中app\models\Contact::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::load方法的具体用法?PHP Contact::load怎么用?PHP Contact::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Contact
的用法示例。
在下文中一共展示了Contact::load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate($type)
{
$incoming = new Incoming();
$contact = new Contact();
if ($incoming->load(Yii::$app->request->post()) && $contact->load(Yii::$app->request->post())) {
$contact->type = Contact::PERSON;
$isValid = $incoming->validate();
$isValid = $contact->validate() && $isValid;
if ($isValid) {
$incoming->save(false);
$contact->save(false);
$from = new Endpoint();
$from->type = Endpoint::FROM;
$from->doc_id = $incoming->id;
$from->contact_id = $contact->id;
$from->save(false);
return $this->redirect(['index']);
} else {
Yii::trace($contact->errors);
}
}
$incoming->type = Incoming::PERSON;
$incoming->docdate = date('Y-m-d');
return $this->render('create', ['incoming' => $incoming, 'contact' => $contact]);
}
示例2: actionCreate
/**
* Creates a new Contact model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Contact();
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
/**
* Creates a new Contact model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Contact();
if (!\Yii::$app->user->can('createPost', ['post' => $model])) {
throw new NotFoundHttpException('You havent access to create item.');
}
$model->setScenario(Contact::SCENARIO_ADD_CONTACT);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: actionCreate
/**
* Creates a new Contact model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Contact();
$infoCompany = Infocompany::findOne(['id' => 1]);
if ($model->load(Yii::$app->request->post())) {
$model->fullname = $_POST['genderName'] . " " . $model->fullname;
if ($model->save()) {
//return $this->redirect(['create', 'id' => $model->id]);
Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh();
}
} else {
return $this->render('create', ['model' => $model, 'infoCompany' => $infoCompany]);
}
}
示例5: actionCreate
/**
* Creates a new Contact model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate()
{
Yii::$app->response->format = Response::FORMAT_JSON;
// Define that response will be on json format
$model = new Contact();
$model->scenario = Contact::SCENARIO_CREATE;
// Scenarios allow us to configure which attributes are safe to massive assignment
$data = Json::decode(Yii::$app->request->post('model'));
// First of all we decode json data to data in Yii conventions
if ($model->load($data) && $model->save()) {
return ['statusCode' => 200, 'model' => $model];
} else {
// Return error 400 if no data or not created
return new HttpException(400);
}
}
示例6: actionWorkers
public function actionWorkers($id)
{
$dept = $this->loadModel($id);
$worker = new Contact(['scenario' => Contact::SCENARIO_NEW_WORKER]);
if ($worker->load(Yii::$app->request->post())) {
$worker->type = Contact::COWORKER;
$worker->dept = $dept->id;
if ($worker->save()) {
if ($worker->isChief) {
$dept->chief_id = $worker->id;
$dept->save();
}
$worker = new Contact(['scenario' => Contact::SCENARIO_NEW_WORKER]);
}
}
return $this->render('workers', ['dept' => $dept, 'worker' => $worker, 'workersDataProvider' => $this->workersDataProvider($dept->id)]);
}
示例7: actionIndex
public function actionIndex()
{
$model = new Contact();
$msgs = Contact::find()->orderBy('id DESC')->limit('50')->all();
if ($model->load(Yii::$app->request->post())) {
$model->admin_id = Yii::$app->user->id;
$model->time = time();
$model->save();
$this->redirect('contact');
}
// проверка на время публикации (1 час)
$openContactForm = true;
$restTime = 0;
foreach ($msgs as $one) {
if ($one['admin_id'] == Yii::$app->user->id && $one['time'] >= time() - 60 * 60) {
$openContactForm = false;
$restTime = ceil(($one['time'] - (time() - 60 * 60)) / 60);
break;
}
}
return $this->render('index', ['model' => $model, 'msgs' => $msgs, 'openContactForm' => $openContactForm, 'restTime' => $restTime]);
}
示例8: actionAddContact
/**
* Add a contact to an existing Supplier.
* @param integer $id
* @return mixed
*/
public function actionAddContact($id)
{
$supplier = $this->findModel($id);
$model = new Contact();
$model->supplier_id = $supplier->id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $supplier->id]);
} else {
return $this->render('add-contact', ['model' => $model, 'supplier' => $supplier]);
}
}