name = $name; $this->builder = $builder; $this->title = $this->formatLabel($title); } /** * Set parent model for relation. * * @param Fluent|Model $model * @return $this|Fluent */ public function model($model = null) { if ($model === null) { return $this->model; } $this->model = $model; return $this; } /** * @param int $width * @return $this */ public function width(int $width, int $_ = 2) { $this->width = $width; return $this; } protected function build() { $view = call_user_func($this->builder, $this->model); if ($view instanceof Show) { $view->panel()->title($this->title); return $view->render(); } if ($view instanceof Grid) { return $view->setName($this->name) ->title($this->title) ->disableBatchDelete() ->render(); } return Helper::render($view); } /** * Render this relation panel. * * @return string */ public function render() { return <<{$this->build()} HTML; } }