Skip to content

Commit

Permalink
All columns have options "html" and "width"
Browse files Browse the repository at this point in the history
  • Loading branch information
underwear committed Nov 16, 2020
1 parent 27f5a24 commit 8738432
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
39 changes: 38 additions & 1 deletion src/Columns/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ abstract class Column implements JsonSerializable
* @var string|null
*/
protected $type = 'text';

/**
* @var bool
*/
protected $html = false;

/**
* @var string|null
*/
protected $width = null;

/**
* @var string
Expand Down Expand Up @@ -147,6 +157,31 @@ public function getDisplayedValued($row, $attribute = null)
return $value;
}


/**
* @param bool|null $value
*
* @return Text
*/
public function html(?bool $value = true): self
{
$this->html = $value;

return $this;
}

/**
* @param string|null $value
*
* @return Text
*/
public function width(?string $value): self
{
$this->width = $value;

return $this;
}

/**
* Resolve the given attribute from the given resource.
*
Expand All @@ -168,7 +203,9 @@ public function jsonSerialize(): array
return [
'label' => $this->getName(),
'field' => $this->getAttribute(),
'type' => $this->getType()
'type' => $this->getType(),
'html' => $this->html,
'width' => $this->width,
];
}
}
36 changes: 0 additions & 36 deletions src/Columns/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ class Text extends Column implements Searchable, Sortable, Filterable
*/
protected $type = 'text';

/**
* @var bool
*/
protected $html = false;

/**
* @var string|null
*/
protected $width = null;

/**
* @var null|string
*/
Expand Down Expand Up @@ -158,30 +148,6 @@ public function filter($queryBuilder, array $values)
});
}

/**
* @param bool|null $value
*
* @return Text
*/
public function html(?bool $value = true): self
{
$this->html = $value;

return $this;
}

/**
* @param string|null $value
*
* @return Text
*/
public function width(?string $value): self
{
$this->width = $value;

return $this;
}

/**
* @param Builder $queryBuilder
* @param string $searchQuery
Expand Down Expand Up @@ -213,9 +179,7 @@ public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), [
'sortable' => $this->isSortable(),
'html' => $this->html,
'filterOptions' => $this->filterOptions ? $this->filterOptions->jsonSerialize() : null,
'width' => $this->width
]);
}
}

0 comments on commit 8738432

Please sign in to comment.