callback = $callback; $this->show = $show; $this->fields = new Collection(); call_user_func($this->callback, $this); } /** * Render the row. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function render() { return view('admin::show.row', ['fields' => $this->fields]); } /** * @return \Illuminate\Support\Collection */ public function getFields() { return $this->fields; } /** * Set width for a incomming field. * * @param int $width * * @return $this */ public function width($width = 12) { $this->defaultFieldWidth = $width; return $this; } /** * @param $name * @param string $label * * @return \Dcat\Admin\Show\Field */ public function field($name, $label = '') { $field = $this->show->field($name, $label); $this->pushField($field); return $field; } /** * Add field. * @param $name * * @return \Dcat\Admin\Show\Field|\Illuminate\Support\Collection */ public function __get($name) { $field = $this->show->__get($name); $this->pushField($field); return $field; } /** * @param $method * @param $arguments * * @return \Dcat\Admin\Show\Field */ public function __call($method, $arguments) { $field = $this->show->__call($method, $arguments); $this->pushField($field); return $field; } /** * @param $field */ public function pushField($field) { $this->fields->push([ 'width' => $this->defaultFieldWidth, 'element' => $field, ]); } }