displayFn = Closure::fromCallable([$this, 'defaultDisplay']); } public static function make(string $name, $title) : static { return new static($name, $title); } private function defaultDisplay(Model $row, Column $column) { return $row->{$column->name}; } public function display(callable $fn) : static { $this->displayFn = Closure::fromCallable($fn); return $this; } public function sortable(callable $fn) : static { $this->sortFn = Closure::fromCallable($fn); return $this; } public function searchable(callable $fn) : static { $this->searchFn = Closure::fromCallable($fn); return $this; } public function attributes(callable $fn) : static { $this->attributesFn = Closure::fromCallable($fn); return $this; } public function view(Model $row) { $attributes = $this->attributesFn?->call($this, $row) ?? []; $attributes = new ComponentAttributeBag($attributes); $content = $this->displayFn->call($this, $row, $this); return view('laralight-tables::column', compact('attributes', 'content')); } }