diff --git a/stubs/modules/User/Models/User.php b/stubs/modules/User/Models/User.php index d495ace..7ecec98 100644 --- a/stubs/modules/User/Models/User.php +++ b/stubs/modules/User/Models/User.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Modules\AdminAuth\Notifications\ResetPassword; -// use Modules\Traits\ActivityLog; +// use Modules\Support\Traits\ActivityLog; use Modules\Support\Traits\Searchable; use Spatie\Permission\Traits\HasRoles; diff --git a/stubs/tests/Feature/Support/ActivityLogTraitTest.php b/stubs/tests/Feature/Support/ActivityLogTraitTest.php new file mode 100644 index 0000000..89b4168 --- /dev/null +++ b/stubs/tests/Feature/Support/ActivityLogTraitTest.php @@ -0,0 +1,37 @@ +id(); + $table->string('name')->nullable(); + $table->timestamps(); + }); +}); + +it('logs the activity for the model', function () { + $model = new class extends Model + { + use ActivityLog; + + protected $table = 'items'; + + protected $guarded = []; + }; + + $item1 = $model->create(['name' => 'Item 1']); + + $item1->delete(); + + $this->assertDatabaseHas('activity_log', [ + 'subject_id' => $item1->id, + 'subject_type' => get_class($item1), + 'description' => 'deleted', + ]); +});