Audit log

Creates a logbook based on changes in an eloquent model

Back to Audit log Support

jonatan.carroza78866
jonatan.carroza78866

Hi, I just add the last line

<?php namespace Rw\PageBuilder\Models;

use Model; use Cms\Classes\Page as CmsPage; use October\Rain\Database\Traits\Sortable; use RW\Utils\Classes\Traits\SeoExtendable; use October\Rain\Database\Traits\Sluggable; use \October\Rain\Database\Traits\Validation; use Rw\Utils\Classes\Traits\SortableRelations; use Jacob\Logbook\Traits\LogChanges;

But when I save, the table jacob_logbook_logs is still empty.

What is wrong?

Jacob
Jacob

Hi,

Did you also add the use \Jacob\Logbook\Traits\LogChanges; to your model?

class MyModel extends Model
{
    use \Jacob\Logbook\Traits\LogChanges; // use trait here
jonatan.carroza78866
jonatan.carroza78866

Yes, I add use \Jacob\Logbook\Traits\LogChanges;

But nothing happen.

<pre> <?php namespace Rw\PageBuilder\Models;

use Model; use Cms\Classes\Page as CmsPage; use October\Rain\Database\Traits\Sortable; use RW\Utils\Classes\Traits\SeoExtendable; use October\Rain\Database\Traits\Sluggable; use \October\Rain\Database\Traits\Validation; use Rw\Utils\Classes\Traits\SortableRelations;

/**

  • Model */ class SecundaryPage extends Model { use Validation; use Sortable; use SortableRelations; use SeoExtendable; use \Jacob\Logbook\Traits\LogChanges;

    /**

    • @var string The database table used by the model. */ public $table = 'rw_pagebuilder_pages';

    /**

    • @var array Validation rules */ public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];

    public $rules = [ 'slug' => 'unique:rw_pagebuilder_pages', ];

    public $translatable = [ 'name', ['slug', 'index' => true ], ];

    public $belongsTo = [ 'category' => [Category::class], ];

    public $belongsToMany = [ 'blocks' => [ Block::class, 'table' => 'rw_pagebuilder_block_page', 'pivot' => ['sort_order'], 'key' => 'page_id', 'otherKey' => 'block_id' ], ];

    public $pivotSortableRelations = [ 'blocks' => 'sort_order', ];

    public static function translateParams($params, $oldLocale, $newLocale) { $newParams = $params; foreach ($params as $paramName => $paramValue) { $records = self::transWhere($paramName, $paramValue, $oldLocale)->first();

        if ($records) {
            $records->translateContext($newLocale);
            $newParams[$paramName] = $records->$paramName;
        }
    }
    
    return $newParams;

    } } </pre>

1-3 of 3