/** * Returns the show entity view. * Requires the id of the entity. * * @param int id The id of the entity to show * @param string $view_name The name of the view, defaults to 'show'. */ public function getShow($id = null, $view_name = 'show') { $model_class = self::MODEL_CLASS; try { $entity = $this->getDetailsCustomQuery(false, $model_class, $id); } catch (ModelNotFoundException $ex) { // Prepare the error message $error = $this->LMessage->{$model_class::one_entity() . '_not_found'}(compact('id')); // Redirect to the entities index page with an error message return $this->getRedirectFor('index')->with('error', $error); } $entity_ref = $model_class::one_entity(); ${$entity_ref} = $entity; $view_params = array_merge(compact($model_class::one_entity()), $this->getDetailsAdditionalEntities()); //ajax view, maybe will be fixed in the future ... if (Input::has('select') && $this->select_from_show === true) { UsageHelper::deprecated(Input::has('select'), 'Input', 'select', 'ajax'); UsageHelper::deprecated($this->select_from_show, 'controller variable', 'select_from_show', 'enable_ajax_show'); \Log::debug('Use dedicated controller method.'); //select from show is used for showing the entity details with ajax, //so no external layout is involved $view_name = 'select_from_show'; } // Return the right view with its parameters return $this->getViewFor($view_name, $view_params); }
protected function getViewFor($action, $params = array()) { UsageHelper::deprecated($action == "select_from_index", 'view', 'select_from_index', 'index_ajax'); UsageHelper::deprecated($action == "select_from_show", 'view', 'select_from_show', 'show_ajax'); $model_class = static::MODEL_CLASS; $many_entities = $model_class::many_entities(); $params["many_entities_route"] = self::many_entities_route(); $params["one_entity_route"] = self::one_entity_route(); return View::make($this->getViewPrefix() . $many_entities . "." . $action, $params); }
/** * Returns the page for the entity index form. * * @param array filters The list of filters to be applied to the query for the index * @param string view The view name, defaults to 'index'. * * @return View The view to show */ public function getIndex($filters = array(), $view_name = 'index') { $model_class = self::MODEL_CLASS; $current_query = $this->getSummaryCustomQuery($model_class, $filters); // Checking filters ? // ..... not implemented // Applying filters (if any) if (isset($this->import_select_filters)) { foreach ($this->import_select_filters as $f => $f_spec) { if (Input::has($f)) { $filters[] = QueryFilterFactory::$f_spec($f, Input::get($f)); } } } $current_query = QueryFilterFactory::applyAll($current_query, $filters); // Do we want to include the deleted customers? if (Input::get('withDeleted')) { $entities = $current_query->withTrashed()->get(); } elseif (Input::get('onlyDeleted')) { $entities = $current_query->onlyTrashed()->get(); } else { // Grab all the entities $entities = $current_query->get(); } $one_entity = $model_class::one_entity(); $many_entities = $model_class::many_entities(); $entity_ref = $model_class::many_entities(); ${$entity_ref} = $entities; $entity_params = compact($model_class::many_entities(), "one_entity", "many_entities"); foreach ($filters as $flt) { $entity_params[$flt->getKey()] = $flt->getValue(); } $view_params = array_merge($entity_params, $this->getSummaryAdditionalEntities()); //ajax view, maybe will be fixed in the future ... //show the select for the elements - this is used for showing the // select control inside the form with all the needed data // no external layout is involved if (Input::has("select") && $this->select_from_index === true) { UsageHelper::deprecated(Input::has('select'), 'input', 'select', 'ajax'); UsageHelper::deprecated($this->select_from_index, 'controller variable', 'select_from_index', 'enable_ajax_index'); \Log::debug('Use dedicated controller method.'); $view_name = 'select_from_index'; } // Return the right view with its parameters return $this->getViewFor($view_name, $view_params); }