本文整理匯總了PHP中app\models\Event::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::save方法的具體用法?PHP Event::save怎麽用?PHP Event::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Event
的用法示例。
在下文中一共展示了Event::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postSubmit
public function postSubmit(EventReq $req)
{
$event = new Event();
$event->save();
$event->staff()->attach(\Auth::user(), ['created_at' => $event->created_at, 'updated_at' => $event->updated_at]);
$id_slug = slugify($event->id, $event->title);
return redirect()->action('EventController@getDetails', $id_slug);
}
示例2: 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()]);
}
示例3: 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]);
}
}
示例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
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));
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$event = new Event();
$event->event_name = "Test Event";
$event->event_start_date = Carbon::createFromFormat('Y-m-d h:i A', '2016-05-21 12:00 PM')->toDateTimeString();
$event->event_end_date = Carbon::createFromFormat('Y-m-d h:i A', '2016-05-21 3:30 PM')->toDateTimeString();
$user = User::find(1);
$event->user_id = $user->id;
$event->save();
}
示例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)
{
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]);
}
}
}
示例8: edit
public function edit(EventRequest $request, Event $event)
{
$this->authorize('edit-event');
$input = $request->all();
$event->update($input);
if ($request->hasFile('image')) {
$event->image = $this->handleUpload($request);
}
$event->save();
event(new EventChanged($event, ['type' => 'event', 'status' => 'edited']));
$request->session()->flash('success', 'Event has been updated.');
return redirect('/event/' . $event->id);
}
示例9: store
public function store(Request $request)
{
$input = Input::except('token');
$event = new Event();
$validator = $event->getValidator($input);
if ($validator->fails()) {
return $this->respondInvalidData($validator->errors());
}
$event->fill($input);
$event->user_id = Auth::user()->id;
$event->save();
return $this->respondCreateSuccess($event->event_name . ' created');
}
示例10: 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"));
}
}
示例11: createEvent
public static function createEvent(EEvent $event, UserId $event_owner, $self = true, UserId $user_connected = null, $data_connected = null)
{
$e = new Event();
$e->event_owner = $event_owner->getId();
$e->event_type = $event->getValue();
if (!is_null($user_connected)) {
$e->event_user_connected = $user_connected->getId();
}
$data_c = [];
$data_c['self_mode'] = $self;
$e->event_data_connected = json_encode($data_c);
$date = new \DateTime();
$e->date = $date->format("Y-m-d H:i:s");
$e->save();
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// ---------------------------------------------------------------------
// CONFERENCE 1
// ---------------------------------------------------------------------
$conference = ['name' => 'India Conference', 'description' => 'A conference in India.', 'start_date' => '2016-03-01', 'end_date' => '2016-03-31', 'address' => 'Sansad Marg, Connaught Place, New Delhi, Delhi 110001, India', 'city' => 'New Delhi', 'country' => 'India', 'capacity' => 1000, 'status' => 'approved'];
$conference = Conference::create($conference);
$event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-01', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => 'Sansad Marg, Connaught Place, New Delhi, Delhi 110001, India', 'city' => 'New Delhi', 'country' => 'India', 'capacity' => 1000, 'status' => 'approved'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
// ---------------------------------------------------------------------
// CONFERENCE 2
// ---------------------------------------------------------------------
$conference = ['name' => 'Canada Conference', 'description' => 'A conference in Canada.', 'start_date' => '2016-05-11', 'end_date' => '2016-05-20', 'address' => '1055 Canada Pl, Vancouver, BC V6C 0C3, Canada', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 1000, 'status' => 'approved'];
$conference = Conference::create($conference);
$event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-11', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => '1055 Canada Pl, Vancouver, BC V6C 0C3, Canada', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 1000, 'status' => 'approved'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
// ---------------------------------------------------------------------
// CONFERENCE 3
// ---------------------------------------------------------------------
$conference = ['name' => 'France Conference', 'description' => 'A conference in France.', 'start_date' => '2016-05-21', 'end_date' => '2016-05-30', 'address' => '17 Boulevard Saint-Jacques, Paris 75014, France', 'city' => 'Paris', 'country' => 'France', 'capacity' => 1000, 'status' => 'approved'];
$conference = Conference::create($conference);
$event = ['name' => 'Opening Ceremony', 'description' => 'Welcome!', 'facilitator' => 'TBD', 'date' => '2016-05-21', 'start_time' => '09:00:00', 'end_time' => '10:00:00', 'address' => '17 Boulevard Saint-Jacques, Paris 75014, France', 'city' => 'Paris', 'country' => 'France', 'capacity' => 1000, 'status' => 'approved'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
// ---------------------------------------------------------------------
// CONFERENCE 4
// ---------------------------------------------------------------------
$conference = ['name' => 'CPSC 319 Final Demos', 'description' => 'Teams present their projects.', 'start_date' => '2016-03-31', 'end_date' => '2016-04-07', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'approved'];
$conference = Conference::create($conference);
$event = ['name' => 'Project 2 Final Demos', 'description' => 'Teams 5 to 8 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-03-31', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'approved'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
$event = ['name' => 'Project 3 Final Demos', 'description' => 'Teams 9 to 12 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-04-05', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'pending'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
$event = ['name' => 'Project 1 Final Demos', 'description' => 'Teams 1 to 4 present their projects.', 'facilitator' => 'Dr Ahmed Awad', 'date' => '2016-04-07', 'start_time' => '12:30:00', 'end_time' => '14:00:00', 'address' => 'Hugh Dempster Pavilion, 6245 Agronomy Road, Vancouver, BC V6T 1Z4', 'city' => 'Vancouver', 'country' => 'Canada', 'capacity' => 100, 'status' => 'pending'];
$event = new Event($event);
$event->conference()->associate($conference);
$event->save();
}
示例13: store
/**
* Create an Event for a Conference.
*
* @param EventRequest $request
* @param int $cid
* @return Response
*/
public function store(EventRequest $request, $cid)
{
try {
$user = $this->getUser($request);
$conference = Conference::find($cid);
if (!$conference->exists()) {
return response()->error(404, 'Conference Not Found');
}
$event = new Event($request->all());
$event->conference()->associate($conference);
$event->save();
$event->managers()->attach($user);
$this->addActivity($user->getKey(), 'requested', $event->getKey(), 'event');
return response()->success();
} catch (Exception $e) {
return response()->error();
}
}
示例14: 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]);
}
}
示例15: Event
<div class="row">
<div class="col-lg-12 line99">
</div>
</div>
<br>
<div class="col-lg-12 textEvent2">
<?php
$customer = new Event();
$idUser = Yii::$app->user->identity->id;
$customer->idUser = $idUser;
$customer->textEvent = Html::encode($model->subject);
$customer->Date = "2000-" . Html::encode($model->month) . "-" . Html::encode($model->day);
$customer->save();
$day = Html::encode($model->day);
$month = Html::encode($model->month);
$Month_rus = ['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'];
$showMonth = $Month_rus[$month - 1];
echo "<b>" . $day . " " . $showMonth . " </b> будет <b>" . Html::encode($model->subject) . " </b>!";
?>
</div>
<div class="col-lg-12 ">
<div class="btn-toolbar">
<div class="btn-group btn-group-lg">
<a class="btn btn-default addCase" href="<?php
echo \Yii::$app->urlManager->createUrl(['site/index']);
?>