Add $event property to Recording event
Feature or problem being solved
When fireing the Recording event it would be nice have the fireing event also available (created, update, deleted, ...) As it is now it, is not possible to determine the triggered event before the ledger gets written.
Further details
I use the the Recording Event to look for changes in the model and abort if no changes where found (e.g. only the relation gets changed) but a 'deleted' event has no changes on the model and so it aborts too. As it is now, there is no possibility to implement abort logic which relates to the triggered eloquent-event.
Something like this could be sufficient:
In Accountant.php:
if ($this->container->make('events')->until(new Recording($model, $driver, $pivotRelation, $pivotProperties, $event)) === false) {
return;
}
and in Events/Recording.php:
public $event;
public function __construct(Recordable $model, LedgerDriver $driver, string $pivotRelation = null, array $pivotProperties = [], $event)
{
$this->model = $model;
$this->driver = $driver;
$this->pivotRelation = $pivotRelation;
$this->pivotProperties = $pivotProperties;
$this->event = $event;
}