class = $class; $this->text = $text; $this->path = $path; $this->actions = $this->getActions($actions); } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|string */ public function render() { return view('components.index.bulkaction.index'); } protected function getActions($actions) { if (! empty($actions)) { return $actions; } if (class_exists($this->class)) { $bulk_action = app($this->class); event(new BulkActionsAdding($bulk_action)); $this->text = $bulk_action->text; if (is_array($bulk_action->path)) { $this->path = route('bulk-actions.action', $bulk_action->path); } else { $this->path = url('common/bulk-actions/' . $bulk_action->path); } } else { $bulk_action = new \stdClass(); $bulk_action->text = ''; $bulk_action->path = ''; $bulk_action->actions = []; $bulk_action->icons = []; event(new BulkActionsAdding($bulk_action)); if (is_array($bulk_action->path)) { $this->path = route('bulk-actions.action', $bulk_action->path); } else { $this->path = url('common/bulk-actions/' . $bulk_action->path); } } $actions = []; if ($bulk_action->actions) { foreach ($bulk_action->actions as $key => $action) { if ((isset($action['permission']) && ! user()->can($action['permission']))) { continue; } if (empty($action['icon']) && array_key_exists($key, $bulk_action->icons)) { $action['icon'] = $bulk_action->icons[$key]; } $actions[$key] = $action; } } return $actions; } }