LaravelRUS /
SleepingOwlAdmin
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SleepingOwl\Admin\Traits; |
||
| 4 | |||
| 5 | use Closure; |
||
| 6 | |||
| 7 | trait VisibleCondition |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var Closure|null |
||
| 11 | */ |
||
| 12 | protected $visibleCondition; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @return bool |
||
| 16 | */ |
||
| 17 | 1 | public function isVisible() |
|
| 18 | { |
||
| 19 | 1 | if (is_callable($this->visibleCondition)) { |
|
| 20 | 1 | return (bool) call_user_func($this->visibleCondition, $this->getModel()); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 21 | } |
||
| 22 | |||
| 23 | return true; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param Closure $condition |
||
| 28 | * |
||
| 29 | * @return $this |
||
| 30 | */ |
||
| 31 | 1 | public function setVisibilityCondition(Closure $condition) |
|
| 32 | { |
||
| 33 | 1 | $this->visibleCondition = $condition; |
|
| 34 | |||
| 35 | 1 | return $this; |
|
| 36 | } |
||
| 37 | } |
||
| 38 |