本文整理汇总了PHP中app\models\Activity::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::save方法的具体用法?PHP Activity::save怎么用?PHP Activity::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Activity
的用法示例。
在下文中一共展示了Activity::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$attendance_application = ['user_id' => rand(1, 8), 'activity_type' => 'request', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$attendance_application_update = ['user_id' => rand(1, 8), 'activity_type' => 'update', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$attendance_application_approved = ['user_id' => rand(1, 8), 'activity_type' => 'approved', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$conference_denied = ['user_id' => rand(1, 8), 'activity_type' => 'denied', 'source_id' => rand(1, 4), 'source_type' => 'conference'];
$attendance_application_deleted = ['user_id' => rand(1, 8), 'activity_type' => 'deleted', 'source_id' => rand(1, 4), 'source_type' => 'conference application', 'profile_id' => rand(1, 8)];
$ev_attendance_application = ['user_id' => rand(1, 8), 'activity_type' => 'request', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$event_update = ['user_id' => rand(1, 8), 'activity_type' => 'update', 'source_id' => rand(1, 6), 'source_type' => 'event'];
$ev_attendance_application_approved = ['user_id' => rand(1, 8), 'activity_type' => 'approved', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$ev_attendance_application_denied = ['user_id' => rand(1, 8), 'activity_type' => 'denied', 'source_id' => rand(1, 6), 'source_type' => 'event application', 'profile_id' => rand(1, 8)];
$ev_deleted = ['user_id' => rand(1, 8), 'activity_type' => 'deleted', 'source_id' => rand(1, 6), 'source_type' => 'event'];
$attendance_application = new Activity($attendance_application);
$attendance_application->save();
$attendance_application_deleted = new Activity($attendance_application_deleted);
$attendance_application_deleted->save();
$attendance_application_approved = new Activity($attendance_application_approved);
$attendance_application_approved->save();
$attendance_application_update = new Activity($attendance_application_update);
$attendance_application_update->save();
$conference_denied = new Activity($conference_denied);
$conference_denied->save();
$ev_deleted = new Activity($ev_deleted);
$ev_deleted->save();
$event_update = new Activity($event_update);
$event_update->save();
$ev_attendance_application = new Activity($ev_attendance_application);
$ev_attendance_application->save();
$ev_attendance_application_denied = new Activity($ev_attendance_application_denied);
$ev_attendance_application_denied->save();
$ev_attendance_application_approved = new Activity($ev_attendance_application_approved);
$ev_attendance_application_approved->save();
}
示例2: log
public static function log($text = null, $params = null, $user_id = null, $contact_id = null)
{
$params = isset($params) ? $params : Request::all();
$browser = "";
foreach ($params as $key => &$param) {
foreach (self::$hides as $hide) {
if (strpos($key, $hide) !== false) {
$param = "***";
}
}
}
$activity = new Activity();
$activity->user_id = isset($user_id) ? $user_id : Auth::user()->id;
$activity->contact_id = isset($contact_id) ? $contact_id : Auth::user()->active_contact->id;
$activity->method = Request::method();
$activity->path = Request::path();
$activity->request = json_encode($params);
$activity->ip_address = Request::ip();
$activity->route = Request::route() ? Request::route()->getName() : NULL;
$activity->text = $text;
$browser = new Browser();
$activity->browser = $browser->getBrowser();
$activity->browser_version = $browser->getVersion();
$activity->os = $browser->getPlatform();
$activity->save();
}
示例3: handle
/**
* Handle the event.
*
* @param PermissionChecked $event
* @return void
*/
public function handle(PermissionChecked $event)
{
$activity = new Activity();
$activity->activity_type = get_class($event->permission);
$activity->activity_id = $event->permission->id;
$activity->user_id = $event->user->id;
$activity->save();
}
示例4: actionCreate
public function actionCreate()
{
$activity = new Activity();
if ($activity->load(Yii::$app->request->post()) && $activity->save()) {
$activities = Activity::find()->where(['belong_to' => $this->data_post['belong_to']])->orderBy('id DESC')->limit(5)->offset(0)->all();
$this->data_post = array_merge($this->data_post, ['activities' => $activities]);
return ['errors' => '', 'data' => $this->renderPartial('@widget/views/activities/_list', $this->data_post)];
}
}
示例5: actionCreate
public function actionCreate()
{
$model = new Activity();
if ($model->load(Yii::$app->request->post())) {
$model->save();
//var_dump($model->getErrors()); die;
}
return $this->render('create', array('model' => $model));
}
示例6: actionCreate
/**
* Creates a new Activity model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Activity();
if (Yii::$app->session->has('program_id')) {
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
throw new \yii\web\NotFoundHttpException();
}
}
示例7: actionReleaseActivity
public function actionReleaseActivity()
{
$request = yii::$app->request;
$session = yii::$app->session;
$user = $session['user'];
$activity = new Activity();
$activity['id'] = Activity::getNewActivityId();
$activity['startdate'] = $request->post('startdate');
$activity['finishdate'] = $request->post('finishdate');
$activity['peoplenum'] = intval($request->post('peoplenum'));
$activity['beginerId'] = $user['id'];
$activity->save();
return $this->render("oneActivity", ['activity' => $activity, 'attendUsers' => array()]);
}
示例8: actionCreate
/**
* Creates a new Activity model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Activity();
if ($model->load(Yii::$app->request->post())) {
$model->user_id = Yii::$app->user->id;
//$model->date = Yii::$app->formatter->asDate('today', 'long');
$model->created_at = date('Y-m-d h:i:s');
if ($model->save()) {
Yii::$app->notification->notify($model->title, $model, Yii::$app->user->identity, Yii::$app->controller->id, '*');
Yii::$app->session->setFlash('success', 'Activity posted successfully.');
return $this->redirect(['index']);
}
} else {
if (Yii::$app->request->isAjax) {
return $this->renderAjax('_form', ['model' => $model]);
} else {
return $this->render('create', ['model' => $model]);
}
}
}
示例9: actionCreate
/**
* Creates a new Activity model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Activity();
if (Yii::$app->request->isPost) {
$postInfo = Yii::$app->request->post();
if (strtotime($postInfo['Activity']['end_time']) <= strtotime($postInfo['Activity']['begin_time'])) {
throw new ServerErrorHttpException('更新状态失败,原因:开始时间不能大于结束时间!');
}
if (strtotime($postInfo['Activity']['sign_up_end_time']) <= strtotime($postInfo['Activity']['sign_up_begin_time'])) {
throw new ServerErrorHttpException('更新状态失败,原因:注册开始时间不能大于注册结束时间!');
}
if (strtotime($postInfo['Activity']['begin_time']) <= strtotime($postInfo['Activity']['sign_up_end_time'])) {
throw new ServerErrorHttpException('更新状态失败,原因:注册结束时间不能大于开始时间!');
}
$postInfo['Activity']['code'] = date('Ymd', time());
if ($model->load($postInfo) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
throw new ServerErrorHttpException('更新状态失败,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE) . '!');
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例10: actionCreate
/**
* Creates a new Activity model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (Yii::$app->user->can('activityCreate')) {
$model = new Activity();
if ($model->load(Yii::$app->request->post())) {
$model->lastModifyTime = date("Y-m-d H:i:s");
$model->Administrator_id = Yii::$app->user->id;
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
return $this->render('create', ['model' => $model]);
} else {
if (Yii::$app->user->isGuest) {
Yii::$app->user->loginRequired();
} else {
throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
}
}
}