Skip to content
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
13 changes: 6 additions & 7 deletions helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,21 +468,20 @@ function getRawSql(\Illuminate\Contracts\Database\Eloquent\Builder|\Illuminate\C

if (! function_exists('getErrors')) {
/**
* Feedback CSS Class.
* Get validation errors.
*
* @param string|null $key
* @param string|null $bag
*
* @return \Illuminate\Support\ViewErrorBag|null
*/
function getErrors(?string $key = null, ?string $bag = null): ?\Illuminate\Support\ViewErrorBag
function getErrors(?string $bag = null): ?\Illuminate\Support\ViewErrorBag
{
$errors = session('errors');
if (empty($key) || ! $errors instanceof \Illuminate\Support\ViewErrorBag) {
if (! $errors instanceof \Illuminate\Support\ViewErrorBag) {
return null;
}
if ($bag) {
if (empty($errors->$bag->all())) {
if (empty($errors->{$bag}->all())) {
return null;
}
$errors = $errors->$bag;
Expand All @@ -494,7 +493,7 @@ function getErrors(?string $key = null, ?string $bag = null): ?\Illuminate\Suppo

if (! function_exists('hasError')) {
/**
* Feedback CSS Class.
* Exist validation error.
*
* @param string|array|null $key
* @param string|null $bag
Expand All @@ -503,7 +502,7 @@ function getErrors(?string $key = null, ?string $bag = null): ?\Illuminate\Suppo
*/
function hasError(string|array|null $key = null, ?string $bag = null): bool
{
if (($errors = getErrors($key, $bag)) instanceof \Illuminate\Support\ViewErrorBag === false) {
if (($errors = getErrors($bag)) instanceof \Illuminate\Support\ViewErrorBag === false) {
return false;
}

Expand Down