Ejemplo n.º 1
0
 /**
  * Treat this method as a controller action.
  * Return view() or other content to display.
  *
  * @param \Yajra\CMS\Entities\Widget $widget
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function run($widget)
 {
     $navigation = app('navigation')->findOrFail($widget->param('navigation_id'));
     if (!$navigation->menus()->count()) {
         return '';
         // return empty string if navigation does not have menu items
     }
     return view($widget->present()->template(), ['config' => $this->config, 'widget' => $widget, 'menu' => 'menu_' . $navigation->type]);
 }
Ejemplo n.º 2
0
 /**
  * Get all published widgets.
  *
  * @return \Illuminate\Support\Collection
  */
 protected function getWidgetsToDisplay()
 {
     // Note:
     // This widget has menu_assignment global scope attached in the query.
     $widgets = Widget::with('permissions')->published()->orderBy('order', 'asc')->get();
     return $widgets->groupBy('position');
 }
Ejemplo n.º 3
0
 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $users = Widget::query()->select('widgets.*')->with(['extension' => function ($query) {
         $query->select('id', 'name');
     }])->withoutGlobalScope('menu_assignment');
     return $this->applyScopes($users);
 }
Ejemplo n.º 4
0
 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function map(Router $router)
 {
     $router->bind('widget', function ($id) use($router) {
         if ($router->is('administrator*')) {
             return Widget::withoutGlobalScope('menu_assignment')->findOrFail($id);
         }
         return Widget::findOrFail($id);
     });
     $this->mapWebRoutes($router);
 }
Ejemplo n.º 5
0
 /**
  * Treat this method as a controller action.
  * Return view() or other content to display.
  *
  * @param \Yajra\CMS\Entities\Widget $widget
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  * @throws \Laracasts\Presenter\Exceptions\PresenterException
  */
 public function run($widget)
 {
     return view($widget->present()->template(), ['config' => $this->config, 'widget' => $widget]);
 }
Ejemplo n.º 6
0
 /**
  * Get widget custom parameter form if any.
  *
  * @param int $id
  * @param int $widget
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
  */
 public function parameters($id, $widget)
 {
     $widget = Widget::withoutGlobalScope('menu_assignment')->findOrNew($widget);
     $extension = $this->repository->findOrFail($id);
     $formView = $extension->param('form');
     if (view()->exists($formView)) {
         return view($formView, compact('widget'));
     }
     return view('widgets.partials.none');
 }