-
-
Notifications
You must be signed in to change notification settings - Fork 671
Expand file tree
/
Copy pathCanSee.php
More file actions
52 lines (46 loc) · 1.23 KB
/
CanSee.php
File metadata and controls
52 lines (46 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
namespace Orchid\Screen;
/**
* Trait CanSee
*
* This trait provides a mechanism to control the visibility of an element in a template.
* It allows developers to conditionally display or hide components based on a boolean flag.
*/
trait CanSee
{
/**
* Determines whether the element should be displayed.
*
* If set to `false`, the element will be hidden and not rendered in the output.
*
* @var bool
*/
private $display = true;
/**
* Set the visibility of the element.
*
* This method allows toggling the visibility of the component.
* If set to `false`, the component will not be included in the rendered template.
*
* @param bool $value The visibility status. `true` to display, `false` to hide.
*
* @return $this
*/
public function canSee(bool $value): self
{
$this->display = $value;
return $this;
}
/**
* Check if the element is visible.
*
* This method returns the current visibility status of the component.
*
* @return bool `true` if the element is visible, `false` if it is hidden.
*/
public function isSee(): bool
{
return $this->display;
}
}