Skip to content

Commit

Permalink
Add dd() and dump() to the request object
Browse files Browse the repository at this point in the history
  • Loading branch information
nakov0301 committed Nov 27, 2020
1 parent 6ecfdb5 commit 858ff9b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Illuminate/Http/Concerns/InteractsWithInput.php
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Str;
use SplFileInfo;
use stdClass;
use Symfony\Component\VarDumper\VarDumper;

trait InteractsWithInput
{
Expand Down Expand Up @@ -462,4 +463,39 @@ protected function retrieveItem($source, $key, $default)

return $this->$source->get($key, $default);
}

/**
* Dump the items and end the script.
*
* @param array|mixed $keys
* @return void
*/
public function dd(...$keys)
{
$keys = is_array($keys) ? $keys : func_get_args();

call_user_func_array([$this, 'dump'], $keys);

exit(1);
}

/**
* Dump the items.
*
* @return $this
*/
public function dump($keys = [])
{
$keys = is_array($keys) ? $keys : func_get_args();

if (count($keys) > 0) {
$data = $this->only($keys);
} else {
$data = $this->all();
}

VarDumper::dump($data);

return $this;
}
}

0 comments on commit 858ff9b

Please sign in to comment.