showInSelect = $this->title !== null; } public static function make(string $name, ?string $title = null) : static { return new static($name, $title); } public function setTable(TableComponent $table) : void { $this->table = $table; } private function defaultSlot(Model $row) { return $row->{$this->name}; } public function slot(callable $fn) : static { $this->slotFn = Closure::fromCallable($fn); return $this; } public function sortable(callable $fn) : static { $this->sortFn = Closure::fromCallable($fn); return $this; } public function tdAttributes(callable $fn) : static { $this->tdAttributesFn = Closure::fromCallable($fn); return $this; } public function showInSelect($show = true) { $this->showInSelect = $show; } public function getShowInSelect() { return $this->showInSelect; } protected function getContent(Model $row) { return $this->slotFn?->call($this, $row, $this) ?? $this->defaultSlot($row); } public function view(Model $row) { $attributes = $this->tdAttributesFn?->call($this, $row) ?? []; $attributes = (new ComponentAttributeBag($attributes))->toHtml(); $content = $this->getContent($row); return new HtmlString("{$content}"); } }