Skip to content

Commit ccf2855

Browse files
authored
Further improvements to validation error handling
1 parent 507fb83 commit ccf2855

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ServiceProvider.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Router;
7+
use Illuminate\Support\Collection;
78
use Illuminate\Contracts\Http\Kernel;
89
use Illuminate\Support\Facades\Blade;
910
use Illuminate\Support\Facades\Session;
@@ -64,13 +65,13 @@ protected function shareValidationErrors()
6465
return (object) [];
6566
}
6667

67-
return (object) collect(Session::get('errors')->getBags())->map(function ($bag) {
68-
return collect($bag->messages())->map(function ($errors) {
68+
return (object) Collection::make(Session::get('errors')->getBags())->map(function ($bag) {
69+
return (object) Collection::make($bag->messages())->map(function ($errors) {
6970
return $errors[0];
70-
});
71+
})->toArray();
7172
})->pipe(function ($bags) {
72-
return $bags->has('default') ? $bags->get('default') : $bags;
73-
})->toArray();
73+
return $bags->has('default') ? $bags->get('default') : $bags->toArray();
74+
});
7475
});
7576
}
7677
}

0 commit comments

Comments
 (0)