本文整理汇总了PHP中Activity::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::save方法的具体用法?PHP Activity::save怎么用?PHP Activity::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
public static function boot()
{
parent::boot();
static::creating(function ($workerunit) {
// dd($workerunit);
// Inherit type, domain and format
if (empty($workerunit->type) or empty($workerunit->domain) or empty($workerunit->format)) {
$j = Job::where('_id', $workerunit->job_id)->first();
$workerunit->type = $j->type;
$workerunit->domain = $j->domain;
$workerunit->format = $j->format;
}
$workerunit->annotationVector = $workerunit->createAnnotationVector();
// Activity if not exists
if (empty($workerunit->activity_id)) {
try {
$activity = new Activity();
$activity->label = "Workerunit is saved.";
$activity->softwareAgent_id = $workerunit->softwareAgent_id;
$activity->save();
$workerunit->activity_id = $activity->_id;
Log::debug("Saving workerunit {$workerunit->_id} with activity {$workerunit->activity_id}.");
} catch (Exception $e) {
if ($activity) {
$activity->forceDelete();
}
//if($workerunit) $workerunit->forceDelete();
throw new Exception('Error saving activity for workerunit.');
}
}
});
}
示例2: logActivity
function logActivity($action, $body = null)
{
$activity = new Activity($this);
$name = $this->logName();
$activity->body = "{$action} {$activity->target_class} {$activity->target_id}" . ($name ? ", \"{$name}\"" : "");
$activity->save();
}
示例3: store
/**
* Store to the database the given entities as entities decendent from the given
* document.
*
* @param $document Parent document -- Must be a document entity on the database.
* @param $entities List of entities to be created as decendents from the given document.
*
* @return multitype:string A status array containing the result status information.
*/
public function store($parent, $units, $type)
{
if (count($units) <= 0 && count($units) >= 10000) {
// We will have problems processing empty files or more than 10,000 entities
return ['error' => 'Unable to process files with more than 10,000 lines: ' . $nEnts . 'found'];
}
$activity = new \Activity();
$activity->softwareAgent_id = $this->softwareComponent->_id;
$activity->save();
$entities = [];
foreach ($units as $unit) {
try {
$entity = new Unit();
$entity->project = $parent->project;
$entity->activity_id = $activity->_id;
$entity->documentType = $type;
$entity->parents = [$parent->_id];
$entity->content = $unit;
$entity->hash = md5(serialize($entity));
$entity->save();
array_push($entities, $entity);
} catch (Exception $e) {
foreach ($entities as $en) {
$en->forceDelete();
}
throw $e;
}
}
\Temp::truncate();
return ['success' => 'Sentences created successfully'];
}
示例4: postAddActivity
public function postAddActivity()
{
$company_id = Session::get('company');
$validator = Validator::make(Input::all(), array('type' => 'required|max:100', 'outcome' => 'required|max:200', 'name' => 'required|max:100', 'date' => 'required'));
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
} else {
$type = Input::get('type');
$outcome = Input::get('outcome');
$name = Input::get('name');
$date = Input::get('date');
$activity = new Activity();
$activity->type = $type;
$activity->outcome = $outcome;
$activity->sales_p_name = $name;
$activity->date = $date;
$activity->cutomer_id = $company_id;
$insertedToActivity = $activity->save();
if ($insertedToActivity) {
return Redirect::route('dashboard');
} else {
return Redirect::route('activityAdd');
}
}
}
示例5: log
function log($activity)
{
$act = new Activity();
$act->message = $activity;
$act->user_id = Auth::user()->id;
$act->save();
}
示例6: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Activity();
$model->attributes = $_POST;
$result = $model->save();
$this->sendAjaxResponse($model);
}
示例7: afterFind
function afterFind(\Model $model, $results, $primary)
{
parent::afterFind($model, $results, $primary);
if ($model->id) {
$data = array('model' => $model->alias, 'model_id' => $model->id, 'activity_type' => 'R', 'user_id' => $model->loginUser['id']);
$activity = new Activity();
$activity->save($data);
}
}
示例8: getOldActivity
protected function getOldActivity($subject, $created)
{
$activity = new Activity(['subject_id' => $subject->getKey(), 'subject_type' => get_class($subject), 'user_id' => 1, 'name' => 'created_post']);
$time = Carbon::createFromTimestamp($created)->toDateTimeString();
$activity->setCreatedAt($time);
$activity->setUpdatedAt($time);
$activity->save();
return $activity;
}
示例9: log
public static function log($activity, User $user = null)
{
if ($user === null) {
$user = User::$me;
}
$a = new Activity();
$a->set('user_id', $user->id);
$a->set('action_date', date("Y-m-d H:i:s"));
$a->set('activity', $activity);
$a->save();
return $a;
}
示例10: store
public function store()
{
$activity = new Activity();
$activity->project_id = Auth::user()->curr_project_id;
$activity->location_id = Input::get('location');
$activity->name = Input::get('name');
$activity->description = Input::get('description');
$activity->agenda = Input::get('agenda');
$activity->coordination = Input::get('coordination');
$activity->save();
Session::flash('message', 'Sukses menambahkan agenda baru');
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Activity();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Activity'])) {
$model->attributes = $_POST['Activity'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->act_id));
}
}
$this->render('create', array('model' => $model));
}
示例12: store
public function store()
{
$ac = new Activity();
$ac->user_id = Auth::user()->id;
$ac->site_id = Input::get('site');
$ac->problem = Input::get('problem');
$ac->activity = Input::get('activity');
$ac->detail_activity = Input::get('dactivity');
$ac->mulai = Carbon::parse(Input::get('mulai'));
$ac->selesai = Carbon::parse(Input::get('selesai'));
$ac->save();
Session::flash('success', 'Data telah dibuat.');
return Redirect::to('/' . Auth::user()->role . '/activity');
}
示例13: TraceIncomingCall
function TraceIncomingCall()
{
require_once 'include/utils/utils.php';
global $adb, $current_user;
global $theme, $app_strings;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$sql = "select * from vtiger_asteriskextensions where userid = " . $current_user->id;
$result = $adb->query($sql);
$asterisk_extension = $adb->query_result($result, 0, "asterisk_extension");
$query = "select * from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension;
$result = $adb->query($query);
if ($adb->num_rows($result) > 0) {
$callerNumber = $adb->query_result($result, 0, "from_number");
$callerName = $adb->query_result($result, 0, "from_name");
$callerType = $adb->query_result($result, 0, "callertype");
if (!empty($callerType)) {
$caller = getCallerName("{$callerType}:" . $callerNumber);
} else {
$caller = getCallerName($callerNumber);
}
$adb->query("delete from vtiger_asteriskincomingcalls where to_number = " . $asterisk_extension);
//prepare the div for incoming calls
$status = "\t<table border='0' cellpadding='5' cellspacing='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style='padding:10px;' colspan='2'><b>Incoming Call</b></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t<table border='0' cellpadding='0' cellspacing='0' class='hdrNameBg'>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Caller Information</b>\n\t\t\t\t\t\t\t<br><b>Number:</b> {$callerNumber}\n\t\t\t\t\t\t\t<br><b>Name:</b> {$callerName}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t\t<tr><td style='padding:10px;' colspan='2'><b>Information from vtigerCRM</b>\n\t\t\t\t\t\t\t<br>{$caller}\n\t\t\t\t\t\t</td></tr>\n\t\t\t\t\t</table>";
require_once 'modules/Calendar/Activity.php';
$focus = new Activity();
$focus->column_fields['subject'] = "Incoming call from {$callerName} ({$callerNumber})";
$focus->column_fields['activitytype'] = "Call";
$focus->column_fields['date_start'] = date('Y-m-d');
$focus->column_fields['due_date'] = date('Y-m-d');
$focus->column_fields['time_start'] = date('H:i');
$focus->column_fields['time_end'] = date('H:i');
$focus->column_fields['eventstatus'] = "Held";
$focus->column_fields['assigned_user_id'] = $current_user->id;
$focus->save('Calendar');
$callerInfo = getCallerInfo("{$callerType}:" . $callerNumber);
if ($callerInfo == false) {
$callerInfo = getCallerInfo(getStrippedNumber($callerNumber));
}
if ($callerInfo != false) {
$tablename = array('Contacts' => 'vtiger_cntactivityrel', 'Accounts' => 'vtiger_seactivityrel', 'Leads' => 'vtiger_seactivityrel');
$sql = "insert into " . $tablename[$callerInfo['module']] . " values (?,?)";
$params = array($callerInfo[id], $focus->id);
$adb->pquery($sql, $params);
}
} else {
$status = "failure";
}
return $status;
}
示例14: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Activity();
// Associate goal with current user.
$model->userId = Yii::app()->user->id;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Activity'])) {
$model->attributes = $_POST['Activity'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'goals' => Goal::model()->findAllByAttributes(array('userId' => $model->userId))));
}
示例15: testActivityCRUD
/**
* Test Activity
*/
public function testActivityCRUD()
{
$activity = new Activity();
$activity->_id = \app\locker\helpers\Helpers::getRandomValue();
$activity->definition = array('type' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()), 'description' => array('en-US' => \app\locker\helpers\Helpers::getRandomValue()));
$result = $activity->save();
$this->assertTrue($result);
// Load activity from db
$aid = $activity->_id;
$db_activity = Activity::find($aid);
$this->assertEquals($db_activity->_id, $activity->_id);
// Delete activity
$db_activity->delete();
$this->assertEquals(Activity::find($aid), NULL);
}