Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 19, 2020
1 parent 5221497 commit f13a1df
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/Illuminate/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,14 @@ public function nest($key, $view, array $data = [])
* Add validation errors to the view.
*
* @param \Illuminate\Contracts\Support\MessageProvider|array $provider
* @param string $bag
* @return $this
*/
public function withErrors($provider, $key = 'default')
public function withErrors($provider, $bag = 'default')
{
$value = $this->parseErrors($provider);

$errors = new ViewErrorBag;

$this->with('errors', $errors->put($key, $value));

return $this;
return $this->with('errors', (new ViewErrorBag)->put(
$bag, $this->formatErrors($provider)
));
}

/**
Expand All @@ -225,13 +222,11 @@ public function withErrors($provider, $key = 'default')
* @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider
* @return \Illuminate\Support\MessageBag
*/
protected function parseErrors($provider)
protected function formatErrors($provider)
{
if ($provider instanceof MessageProvider) {
return $provider->getMessageBag();
}

return new MessageBag((array) $provider);
return $provider instanceof MessageProvider
? $provider->getMessageBag()
: new MessageBag((array) $provider);
}

/**
Expand Down

0 comments on commit f13a1df

Please sign in to comment.