diff --git a/README.md b/README.md index 82ca0ed..d280e5a 100644 --- a/README.md +++ b/README.md @@ -566,6 +566,8 @@ Pixie comes with powerful query events to supercharge your application. These ev #### Available Events + - after-* + - before-* - before-select - after-select - before-insert diff --git a/src/Pixie/EventHandler.php b/src/Pixie/EventHandler.php index 5d202ad..42c399f 100644 --- a/src/Pixie/EventHandler.php +++ b/src/Pixie/EventHandler.php @@ -34,6 +34,19 @@ public function getEvent($event, $table = ':any') if ($table instanceof Raw) { return null; } + + // Find event with * + if(isset($this->events[$table])) { + foreach($this->events[$table] as $name => $e) { + if (stripos($name, '*') > - 1) { + $name = substr($name, 0, strpos($name, '*')); + if (stripos($event, $name) > - 1) { + return $e; + } + } + } + } + return isset($this->events[$table][$event]) ? $this->events[$table][$event] : null; } @@ -95,4 +108,4 @@ public function fireEvents($queryBuilder, $event) } } } -} +} \ No newline at end of file