spatie / laravel-activitylog

Log activity inside your Laravel app
https://docs.spatie.be/laravel-activitylog
MIT License
5.36k stars 714 forks source link

Delete method not resulting in log #1230

Closed tvaughan73 closed 8 months ago

tvaughan73 commented 1 year ago

Describe the bug When deleting a record, depending on the method used, the delete is not logged. Using the destroy method results in the log working as normal. Using the delete method nothing is logged.

To Reproduce Things needed to reproduce the error.

Using delete method will not result in delete being logged.

SomeModel::where(['id' => $id])->delete();

This works as expected:

    $record = SomeModel::where(['id' => $id])->first();
    if ($record) {
        SomeModel::destroy($record->id);
    }

Expected behavior Log should be made when delete method is used.

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information)

Additional context Add any other context about the problem here.

Exception The thrown exception message. No error is thrown.

Stack Trace The full stack trace of the thrown exception.

debuqer commented 1 year ago

The expected behavior is to not log that, because activity-log is only able to log model events automatically and not eloquent queries

SomeModel::where(['id' => $id])->delete();

This is an Eloquent Builder and it's expected to not be logged

You can use activity() helper to log custom events. I think the issue can be safely closed.

spatie-bot commented 8 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.