本文整理汇总了PHP中Revision::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::getTable方法的具体用法?PHP Revision::getTable怎么用?PHP Revision::getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::getTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCreate
/**
* Called after record successfully created
*/
public function postCreate()
{
// Check if we should store creations in our revision history
// Set this value to true in your model if you want to
if (empty($this->revisionCreationsEnabled)) {
// We should not store creations.
return false;
}
if (!isset($this->revisionEnabled) || $this->revisionEnabled) {
$revisions[] = array('revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'created_at', 'old_value' => null, 'new_value' => $this->created_at, 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime());
$revision = new Revision();
\DB::table($revision->getTable())->insert($revisions);
}
}
示例2: postCreate
/**
* Called after record successfully created
*/
public function postCreate()
{
// Check if we should store creations in our revision history
// Set this value to true in your model if you want to
if (empty($this->revisionCreationsEnabled)) {
// We should not store creations.
return false;
}
if (!isset($this->revisionEnabled) || $this->revisionEnabled) {
$changes_to_record = $this->changedRevisionableFields();
$newValue = array();
foreach ($changes_to_record as $key => $change) {
$newValue[$key] = $this->updatedData[$key];
}
$revisions[] = array('revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'created_at', 'old_value' => null, 'new_value' => json_encode($newValue), 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime(), 'ip' => \Request::ip());
$revision = new Revision();
\DB::table($revision->getTable())->insert($revisions);
}
}
示例3: postCreate
/**
* Called after record successfully created
*/
public function postCreate()
{
// Check if we should store creations in our revision history
// Set this value to true in your model if you want to
if (empty($this->revisionCreationsEnabled)) {
// We should not store creations.
return false;
}
if (!isset($this->revisionEnabled) || $this->revisionEnabled) {
$revisions[] = array('revisionable_type' => $this->getMorphClass(), 'revisionable_id' => $this->getKey(), 'key' => self::CREATED_AT, 'old_value' => null, 'new_value' => $this->{self::CREATED_AT}, 'user_id' => $this->getSystemUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime());
$revision = new Revision();
\DB::table($revision->getTable())->insert($revisions);
\Event::fire('revisionable.created', array('model' => $this, 'revisions' => $revisions));
}
}
示例4: postSave
/**
* Called after a model is successfully saved.
*
* @return void
*/
public function postSave()
{
if (isset($this->historyLimit) && $this->revisionHistory()->count() >= $this->historyLimit) {
$LimitReached = true;
} else {
$LimitReached = false;
}
// check if the model already exists
if ((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->updating && !$LimitReached) {
// if it does, it means we're updating
$changes_to_record = $this->changedRevisionableFields();
$revisions = array();
foreach ($changes_to_record as $key => $change) {
$revisions[] = array('revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => $key, 'old_value' => array_get($this->originalData, $key), 'new_value' => $this->updatedData[$key], 'user_id' => $this->getUserId(), 'created_at' => new \DateTime(), 'updated_at' => new \DateTime());
}
if (count($revisions) > 0) {
$revision = new Revision();
\DB::table($revision->getTable())->insert($revisions);
}
}
}
示例5: postDelete
/**
* If softdeletes are enabled, store the deleted time
*/
public function postDelete()
{
if ((!isset($this->revisionEnabled) || $this->revisionEnabled) && $this->isSoftDelete() && $this->isRevisionable('deleted_at')) {
$revisions = array();
$revisions[] = array('revisionable_type' => $this->getTable(), 'revisionable_id' => $this->getKey(), 'key' => 'deleted_at', 'old_value' => null, 'new_value' => $this->deleted_at, 'user_id' => $this->getUserId(), 'created_at' => new \DateTime());
$revision = new Revision();
\DB::table($revision->getTable())->insert($revisions);
}
}