Skip to content

Commit

Permalink
Fixed bug introduced into fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jdw5 committed Apr 25, 2024
1 parent 938190f commit 1aee2d3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 19 deletions.
33 changes: 25 additions & 8 deletions src/Concerns/IsActive.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,52 @@
namespace Jdw5\Vanguard\Concerns;

/**
* Trait IsActive
*
* Set an active property on a class
*
* @property bool $active
*/
trait IsActive
{
/** Defaults to being false */
protected bool $active = false;

/**
* Set the active property
* Set the active property, chainable.
*
* @param bool $active
* @return static
*/
public function active(bool $active = true): static
{
$this->active = $active;
$this->setActive($active);
return $this;
}

/**
* Check if the class is active
* Set the active property quietly.
*
* @param bool $active
*/
protected function setActive(bool $active): void
{
$this->active = $active;
}

/**
* Check if the class is active (alias)
*
* @return bool
*/
public function isActive(): bool
{
return $this->active;
return $this->getActive();
}

/**
* Check if the class is active
*
* @return bool
*/
public function getActive(): bool
{
return $this->evaluate($this->active);
}
}
33 changes: 25 additions & 8 deletions src/Concerns/IsDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,50 @@
namespace Jdw5\Vanguard\Concerns;

/**
* Trait IsDefault
*
* Set whether a class is the default
*
* @property bool $default
*/
trait IsDefault
{
/** Always default to false */
protected $default = false;

/**
* Set the class as default
* Set the class as default, chainable
*
* @return static
*/
public function default(): static
public function default(bool $default = true): static
{
$this->default = true;
$this->setDefault($default);
return $this;
}

/**
* Check if the class is default
* Set the default quietly
*
* @param bool $default
*/
protected function setDefault(bool $default): void
{
$this->default = $default;
}

/**
* Get if the class is default (alias)
*
* @return bool
*/
public function isDefault(): bool
{
return $this->getDefault();
}

/**
* Get if the class is default
*
* @return bool
*/
public function getDefault(): bool
{
return $this->evaluate($this->default);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Concerns/IsHideable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

trait IsHideable
{
/** Whether this column shown be shown */
protected bool $show = true;
/** Whether this column should only be displayed for screen readers */
protected bool $sr_only = false;
/** The breakpoint it should display at */
protected ?Breakpoint $breakpoint = null;

/**
Expand All @@ -22,7 +25,7 @@ public function hide(): static
}

/**
* Set the visibility of the column to hidden
* Set the visibility of the column to hidden (alias)
*
* @return static
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Table/Columns/Concerns/HasFallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
trait HasFallback
{
protected mixed $fallback;
protected mixed $fallback = null;

/**
* Set the fallback value, chainable.
Expand Down Expand Up @@ -40,7 +40,7 @@ protected function setFallback(mixed $fallback): void
*/
public function hasFallback(): bool
{
return isset($this->fallback);
return \is_null($this->getFallback());
}

/**
Expand Down

0 comments on commit 1aee2d3

Please sign in to comment.