本文整理汇总了PHP中app\models\Event::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::load方法的具体用法?PHP Event::load怎么用?PHP Event::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Event();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', ['model' => $model, 'users' => $this->getUsers(), 'typeEvents' => $this->getTypeEvents(), 'events' => $this->getEvents(), 'defaultEvent' => $this->getDefaultEvent()]);
}
示例2: actionCreate
public function actionCreate()
{
$model = new Event();
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()
{
$model = new Event();
if ($model->load(Yii::$app->request->post())) {
$model->save();
//var_dump($model->getErrors()); die;
}
return $this->render('create', array('model' => $model));
}
示例4: actionCreate
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Event();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'zal' => Zal::find()->asArray()->orderBy('name_zal')->all(), 'client' => Client::find()->asArray()->orderBy('name_client')->all(), 'users' => Users::find()->asArray()->where(['status' => 10])->orderBy('username')->all()]);
}
}
示例5: actionCreate
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($date)
{
if (Yii::$app->user->can('admin')) {
$model = new Event();
$model->created_date = $date;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index', 'id' => $model->id]);
} else {
return $this->renderAjax('create', ['model' => $model]);
}
}
}
示例6: save
/**
* Save event data in the database
*
* @param array $data
* @throws \Exception
*/
public function save(array $data)
{
// Check event type
if (!$this->hasValidEventType($data)) {
throw new \Exception(\Yii::t("app", "Event has a invalid type: Should not be recorded."));
}
// Prepare the data for the model validation
$eventData = ['Event' => $data];
// New Event Model
$eventModel = new Event();
// Populate Event Model and Save (with validation)
if (!$eventModel->load($eventData) || !$eventModel->save()) {
throw new \Exception(Yii::t("app", "Error saving Event Model"));
}
}
示例7: actionCreate
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($date)
{
$model = new Event();
$model->user_id = Yii::$app->user->id;
$model->date = $date;
if ($model->load(Yii::$app->request->post())) {
//var_dump($model);
$model->shared_with = implode(',', $model->shared_with);
if ($model->save()) {
Yii::$app->notification->notify($model->title, $model, $model->user, Yii::$app->controller->id, $model->shared_with);
}
return $this->redirect(['view', 'id' => $model->id]);
} elseif (Yii::$app->request->isAjax) {
return $this->renderAjax('_form', ['model' => $model]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例8: actionCreate
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (\Yii::$app->user->isGuest) {
return $this->redirect('/site/denied/');
}
$user = \Yii::$app->user->identity;
if (!$user->admin && count($user->organisations) == 0) {
return $this->redirect('/site/denied/');
}
$model = new Event();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}