callback = $callback; $this->fields = collect(); $this->form = $form; call_user_func($this->callback, $this); } /** * Get fields of this row. * * @return array|Collection */ public function fields() { return $this->fields; } public function setFields(Collection $collection) { $this->fields = $collection; return $this; } /** * @return mixed */ public function getKey() { return $this->form->getKey(); } /** * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Fluent|void */ public function model() { return $this->form->model(); } /** * Set width for a incomming field. * * @param int $width * * @return $this */ public function width($width = 12) { $this->defaultFieldWidth = $width; return $this; } /** * Render the row. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function render() { return view('admin::form.row', ['fields' => $this->fields]); } /** * Add field. * * @param string $method * @param array $arguments * * @return Field|void */ public function __call($method, $arguments) { $field = $this->form->__call($method, $arguments); $field->disableHorizontal(); $this->fields->push([ 'width' => $this->defaultFieldWidth, 'element' => $field, ]); return $field; } }