/**
  * @param WidgetRepository $repository
  * @param int              $handlerId
  *
  * @return mixed|void
  * @throws WidgetException
  */
 public function getHandle(WidgetRepository $repository, $handlerId)
 {
     event('handler.requested', [$handlerId]);
     $widget = $repository->findOrFail($handlerId);
     if (!$widget->isHandler()) {
         throw new WidgetException('Widget handler not found');
     }
     try {
         return app()->call([$widget->toWidget(), 'handle']);
     } catch (ValidationException $e) {
         return $this->throwValidationException($this->request, $e->getValidator());
     }
 }
 /**
  * @param WidgetRepository $repository
  * @param int          $id
  */
 public function getTemplate(WidgetRepository $repository, $id)
 {
     $widget = $repository->findOrFail($id);
     WYSIWYG::loadDefaultCodeEditor();
     $template = $widget->getDefaultFrontendTemplate();
     $content = null;
     if (!$template instanceof View) {
         $template = view($template);
     }
     $content = file_get_contents($template->getPath());
     $this->setContent('widgets.template', compact('content'));
 }