Skip to content

Commit 42383e4

Browse files
committed
formatting
1 parent e2b3596 commit 42383e4

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,51 +86,45 @@ public function makeVisible($attributes)
8686
}
8787

8888
/**
89-
* Make the given, typically visible, attributes hidden.
89+
* Make the given, typically hidden, attributes visible if the given truth test passes.
9090
*
91+
* @param bool|Closure $condition
9192
* @param array|string|null $attributes
9293
* @return $this
9394
*/
94-
public function makeHidden($attributes)
95+
public function makeVisibleIf($condition, $attributes)
9596
{
96-
$this->hidden = array_merge(
97-
$this->hidden, is_array($attributes) ? $attributes : func_get_args()
98-
);
97+
$condition = $condition instanceof Closure ? $condition($this) : $condition;
9998

100-
return $this;
99+
return $condition ? $this->makeVisible($attributes) : $this;
101100
}
102101

103102
/**
104-
* Make the given, typically hidden, attributes visible,
105-
* only if the truth test passes.
103+
* Make the given, typically visible, attributes hidden.
106104
*
107-
* @param bool|Closure $truthTest
108105
* @param array|string|null $attributes
109106
* @return $this
110107
*/
111-
public function makeVisibleIf($truthTest, $attributes)
108+
public function makeHidden($attributes)
112109
{
113-
if ($truthTest instanceof Closure) {
114-
$truthTest = $truthTest($this);
115-
}
110+
$this->hidden = array_merge(
111+
$this->hidden, is_array($attributes) ? $attributes : func_get_args()
112+
);
116113

117-
return $truthTest ? $this->makeVisible($attributes) : $this;
114+
return $this;
118115
}
119116

120117
/**
121-
* Make the given, typically visible, attributes hidden,
122-
* only if the truth test passes.
118+
* Make the given, typically visible, attributes hidden if the given truth test passes.
123119
*
124120
* @param bool|Closure $truthTest
125121
* @param array|string|null $attributes
126122
* @return $this
127123
*/
128-
public function makeHiddenIf($truthTest, $attributes)
124+
public function makeHiddenIf($condition, $attributes)
129125
{
130-
if ($truthTest instanceof Closure) {
131-
$truthTest = $truthTest($this);
132-
}
126+
$condition = $condition instanceof Closure ? $condition($this) : $condition;
133127

134-
return $truthTest ? $this->makeHidden($attributes) : $this;
128+
return value($condition) ? $this->makeHidden($attributes) : $this;
135129
}
136130
}

0 commit comments

Comments
 (0)