本文整理匯總了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);
}
}