Git Product home page Git Product logo

Comments (7)

TimFoerster avatar TimFoerster commented on May 29, 2024

All entries are also stored twice?

from revisions-plugin.

TimFoerster avatar TimFoerster commented on May 29, 2024

All entries are also stored twice?

Both listen to the same events, therefore it will be stored twice.

public static function bootRevisionable()
{
if (!property_exists(get_called_class(), 'revisionable')) {
throw new Exception(sprintf(
'You must define a $revisionable property in %s to use the Revisionable trait.',
get_called_class()
));
}
static::extend(function ($model) {
$model->morphMany['revision_history'] = ['System\Models\Revision', 'name' => 'revisionable'];
$model->bindEvent('model.afterUpdate', function () use ($model) {
$model->revisionableAfterUpdate();
});
$model->bindEvent('model.afterDelete', function () use ($model) {
$model->revisionableAfterDelete();
});
});
}

Revisionable:

public function initializeRevisionable()
    {
        if (!is_array($this->revisionable)) {
            throw new Exception(sprintf(
                'The $revisionable property in %s must be an array to use the Revisionable trait.',
                get_class($this)
            ));
        }

        $this->bindEvent('model.afterUpdate', function () {
            $this->revisionableAfterUpdate();
        });

        $this->bindEvent('model.afterDelete', function () {
            $this->revisionableAfterDelete();
        });
    }

from revisions-plugin.

Samuell1 avatar Samuell1 commented on May 29, 2024

@TimFoerster Hey, you need to only include trait from this plugin, if you add both traits it will fire 2 times.

from revisions-plugin.

TimFoerster avatar TimFoerster commented on May 29, 2024

This is already the case

use Samuell\Revisions\Traits\Revisions;

class Company extends Model
{
    use Revisions;

    protected $revisionable = [
        'section',
        'name',
        'address',
        'type',
        'station_id',
        'content',
        'contacts',
        'divisions',
        'persons'
    ];
    ...    

Error appears only with ocms 3.

from revisions-plugin.

Samuell1 avatar Samuell1 commented on May 29, 2024

@TimFoerster if you remove that bindEvent it works correctly?

from revisions-plugin.

skacco avatar skacco commented on May 29, 2024

I have the same problem.
You need to comment this part on your plugin inside revisions/traits/Revisions.php

       /* $model->bindEvent('model.afterUpdate', function () use ($model) {
            $model->revisionableAfterUpdate();
        });

        $model->bindEvent('model.afterDelete', function () use ($model) {
            $model->revisionableAfterDelete();
        });*/

from revisions-plugin.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.