Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Add dd() and dump() to the request object #35384

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/Illuminate/Http/Concerns/InteractsWithInput.php
Original file line number Diff line number Diff line change
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;
}
}