You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
831 B

  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\ModelSaved;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. class NotifHandler
  7. {
  8. /**
  9. * Create the event listener.
  10. *
  11. * @return void
  12. */
  13. public function __construct()
  14. {
  15. //
  16. }
  17. /**
  18. * Handle the event.
  19. *
  20. * @param ModelSaved $event
  21. * @return void
  22. */
  23. public function handle(ModelSaved $event)
  24. {
  25. $message = json_decode($event->message);
  26. $event_class = 'App\Events\\'.enum('tables.'.$message->data->table_name.'.singular_name').enum('cruds.inverse.'.$message->data->crud_id.'.name');
  27. if (class_exists($event_class)) {
  28. // event(new ('App\Events\\'.$event_class($message)));
  29. $event_class::dispatch($message);
  30. }
  31. }
  32. }