Skip to content

Commit

Permalink
Update RevisionableTrait.php
Browse files Browse the repository at this point in the history
Namespace fix, causing errors in laravel with php 7.4. 
E.G: Call to undefined method Event::dispatch(), explicitly namespacing the classes and removing backslash, fixes the bug.

See: VentureCraft#376
  • Loading branch information
patrickcurl authored Dec 27, 2020
1 parent 2c68e7a commit 5a8c619
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Venturecraft/Revisionable/RevisionableTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php namespace Venturecraft\Revisionable;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Venturecraft\Revisionable\Revisionable;

/*
* This file is part of the Revisionable package by Venture Craft
Expand Down Expand Up @@ -210,8 +213,8 @@ public function postSave()
}
}
$revision = Revisionable::newModel();
\DB::table($revision->getTable())->insert($revisions);
\Event::dispatch('revisionable.saved', array('model' => $this, 'revisions' => $revisions));
DB::table($revision->getTable())->insert($revisions);
Event::dispatch('revisionable.saved', array('model' => $this, 'revisions' => $revisions));
}
}
}
Expand Down Expand Up @@ -248,8 +251,8 @@ public function postCreate()
$revisions = array_merge($revisions[0], $this->getAdditionalFields());

$revision = Revisionable::newModel();
\DB::table($revision->getTable())->insert($revisions);
\Event::dispatch('revisionable.created', array('model' => $this, 'revisions' => $revisions));
DB::table($revision->getTable())->insert($revisions);
Event::dispatch('revisionable.created', array('model' => $this, 'revisions' => $revisions));
}

}
Expand Down Expand Up @@ -278,8 +281,8 @@ public function postDelete()
$revisions = array_merge($revisions[0], $this->getAdditionalFields());

$revision = Revisionable::newModel();
\DB::table($revision->getTable())->insert($revisions);
\Event::dispatch('revisionable.deleted', array('model' => $this, 'revisions' => $revisions));
DB::table($revision->getTable())->insert($revisions);
Event::dispatch('revisionable.deleted', array('model' => $this, 'revisions' => $revisions));
}
}

Expand Down Expand Up @@ -309,8 +312,8 @@ public function postForceDelete()
);

$revision = Revisionable::newModel();
\DB::table($revision->getTable())->insert($revisions);
\Event::dispatch('revisionable.deleted', array('model' => $this, 'revisions' => $revisions));
DB::table($revision->getTable())->insert($revisions);
Event::dispatch('revisionable.deleted', array('model' => $this, 'revisions' => $revisions));
}
}

Expand Down Expand Up @@ -518,7 +521,7 @@ public function disableRevisionField($field)
*
* @return mixed
*/
private function sortJsonKeys($attribute)
private function sortJsonKeys($attribute)DB
{
if(empty($attribute)) return $attribute;

Expand Down

0 comments on commit 5a8c619

Please sign in to comment.