Skip to content

Commit

Permalink
Merge pull request #17 from 22Nick22/updated_by-auth-check
Browse files Browse the repository at this point in the history
Don't touch updated_by if unauthenticated
  • Loading branch information
yajra authored Jun 3, 2021
2 parents d9849e5 + 1006784 commit 578f69f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/AuditableTraitObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Yajra\Auditable;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Schema;

class AuditableTraitObserver
{
Expand Down Expand Up @@ -59,7 +58,7 @@ public function saved(Model $model)
{
$updatedBy = $model->getUpdatedByColumn();

if ($model->$updatedBy <> $this->getAuthenticatedUserId()) {
if ($this->getAuthenticatedUserId() && $model->$updatedBy <> $this->getAuthenticatedUserId()) {
$model->$updatedBy = $this->getAuthenticatedUserId();
$model->save();
}
Expand Down

0 comments on commit 578f69f

Please sign in to comment.