Skip to content

Commit 9ed3046

Browse files
committed
formatting and tweaks
1 parent 3a518c7 commit 9ed3046

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/Illuminate/Http/Concerns/InteractsWithInput.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ public function hasAny($keys)
106106
return Arr::hasAny($input, $keys);
107107
}
108108

109+
/**
110+
* Apply the callback if the request contains the given input item key.
111+
*
112+
* @param string $key
113+
* @param callable $callback
114+
* @return $this|mixed
115+
*/
116+
public function whenHas($key, callable $callback)
117+
{
118+
if ($this->has($key)) {
119+
return $callback(data_get($this->all(), $key)) ?: $this;
120+
}
121+
122+
return $this;
123+
}
124+
109125
/**
110126
* Determine if the request contains a non-empty value for an input item.
111127
*
@@ -163,6 +179,22 @@ public function anyFilled($keys)
163179
return false;
164180
}
165181

182+
/**
183+
* Apply the callback if the request contains a non-empty value for the given input item key.
184+
*
185+
* @param string $key
186+
* @param callable $callback
187+
* @return $this|mixed
188+
*/
189+
public function whenFilled($key, callable $callback)
190+
{
191+
if ($this->filled($key)) {
192+
return $callback(data_get($this->all(), $key)) ?: $this;
193+
}
194+
195+
return $this;
196+
}
197+
166198
/**
167199
* Determine if the request is missing a given input item key.
168200
*
@@ -430,36 +462,4 @@ protected function retrieveItem($source, $key, $default)
430462

431463
return $this->$source->get($key, $default);
432464
}
433-
434-
/**
435-
* Apply the callback if the request contains the given input item key.
436-
*
437-
* @param string $key
438-
* @param callable $callback
439-
* @return $this
440-
*/
441-
public function whenHas($key, callable $callback)
442-
{
443-
if ($this->has($key)) {
444-
$callback(data_get($this->all(), $key));
445-
}
446-
447-
return $this;
448-
}
449-
450-
/**
451-
* Apply the callback if the request contains a non-empty value for the given input item key.
452-
*
453-
* @param string $key
454-
* @param callable $callback
455-
* @return $this
456-
*/
457-
public function whenFilled($key, callable $callback)
458-
{
459-
if ($this->filled($key)) {
460-
$callback(data_get($this->all(), $key));
461-
}
462-
463-
return $this;
464-
}
465465
}

0 commit comments

Comments
 (0)