Laravel-Backpack / activity-log

MIT License
28 stars 7 forks source link

[Feature Request] Command to create a `App\Models\Traits\LogsActivity` #23

Open tabacitu opened 1 year ago

tabacitu commented 1 year ago

Upon installing this package, if I haven't already installed and set up spatie/laravel-activitylog, I want this package to make it easier for me to implement the most common scenario.

I want to run php artisan backpack:activity-log:create-trait, and it will create this:

<?php

namespace App\Models\Traits;

use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity as OriginalLogsActivity;

trait LogsActivity
{
    use OriginalLogsActivity;

    /**
     * Spatie Log Options
     * By default will log only the changes between fillables
     *
     * @return LogOptions
     */
    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()->logAll()->logOnlyDirty();
    }
}