Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #28 from nebulapackage/boolean-labels
Browse files Browse the repository at this point in the history
feat: boolean labels
  • Loading branch information
Larsklopstra authored Oct 1, 2020
2 parents ced0cd8 + 7e61d14 commit fd79a37
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
4 changes: 2 additions & 2 deletions resources/views/components/fields/details/boolean.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

@if (Arr::get($item, $field->getName()) ?? $field->getValue())
<span class="inline-block px-3 py-1 font-mono text-sm font-medium rounded-full bg-success-100 text-success-600">
True
{{ $field->getTrue() }}
</span>
@else
<span class="inline-block px-3 py-1 font-mono text-sm font-medium rounded-full bg-danger-100 text-danger-600">
False
{{ $field->getFalse() }}
</span>
@endif

Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/fields/tables/boolean.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

@if (Arr::get($item, $field->getName()) ?? $field->getValue())
<span class="inline-block px-3 py-1 font-mono text-sm font-medium rounded-full bg-success-100 text-success-600">
True
{{ $field->getTrue() }}
</span>
@else
<span class="inline-block px-3 py-1 font-mono text-sm font-medium rounded-full bg-danger-100 text-danger-600">
False
{{ $field->getFalse() }}
</span>
@endif
8 changes: 4 additions & 4 deletions src/Contracts/NebulaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(string $name)
* Make a field.
*
* @param string $name
* @return NebulaField
* @return $this
*/
public static function make(string $name): self
{
Expand All @@ -38,7 +38,7 @@ public static function make(string $name): self
* Set the name.
*
* @param string $name
* @return NebulaField
* @return $this
*/
public function name(string $name): self
{
Expand All @@ -56,7 +56,7 @@ public function name(string $name): self
* Set the label.
*
* @param mixed $label
* @return NebulaField
* @return $this
*/
public function label($label): self
{
Expand All @@ -69,7 +69,7 @@ public function label($label): self
* Set the value.
*
* @param mixed $value
* @return NebulaField
* @return $this
*/
public function value($value): self
{
Expand Down
38 changes: 38 additions & 0 deletions src/Fields/BooleanField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,42 @@

class BooleanField extends NebulaField
{
protected string $true = 'True';
protected string $false = 'False';

/**
* Set the true label
*
* @param string $label
* @return $this
*/
public function true(string $label): self
{
$this->true = $label;

return $this;
}

/**
* Set the false label
*
* @param string $label
* @return $this
*/
public function false(string $label): self
{
$this->false = $label;

return $this;
}

public function getTrue()
{
return $this->true;
}

public function getFalse()
{
return $this->false;
}
}

0 comments on commit fd79a37

Please sign in to comment.