Reputation: 3097
I installed spatie/activitylog for logging user activity,
the default table name in this package is activity_log
I want change the table name to users_activity_log
I created a model and named Activity
but not work:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Models;
class Activity extends Model
{
//
protected $table = "user_activity_log";
}
How can I do it?
Upvotes: 1
Views: 2078
Reputation: 3097
I found the solution,
1- Create a model : php artisan make:model Activity
2- put this code in your model (change $table
with your table name):
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Activity extends \Spatie\Activitylog\Models\Activity
{
//
protected $table = "user_activity_log";
}
3- publish the logactivity
config file:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
4- change the activity_model
in laravel-activitylog.php
:
'activity_model' => \App\Activity::class
DON'T FORGET to change table name in migration file
Thanks to @devk
Upvotes: 5