generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d4f985
commit aa62769
Showing
4 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace DutchCodingCompany\FilamentSocialite\Traits; | ||
|
||
use Closure; | ||
|
||
trait CanBeHidden | ||
{ | ||
protected bool | Closure $isHidden = false; | ||
|
||
protected bool | Closure $isVisible = true; | ||
|
||
public function hidden(bool | Closure $condition = true): static | ||
{ | ||
$this->isHidden = $condition; | ||
|
||
return $this; | ||
} | ||
|
||
public function visible(bool | Closure $condition = true): static | ||
{ | ||
$this->isVisible = $condition; | ||
|
||
return $this; | ||
} | ||
|
||
public function isHidden(): bool | ||
{ | ||
if ($this->evaluate($this->isHidden)) { | ||
return true; | ||
} | ||
|
||
return ! $this->evaluate($this->isVisible); | ||
} | ||
|
||
public function isVisible(): bool | ||
{ | ||
return ! $this->isHidden(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters