From 0b297c459db3e9ea1a5a77a2843307b962b5660f Mon Sep 17 00:00:00 2001 From: Much Yusron Arif <3467343+yusronarif@users.noreply.github.com> Date: Fri, 17 Nov 2023 09:46:31 +0700 Subject: [PATCH] [fix] geterror validation helper --- helpers.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/helpers.php b/helpers.php index 72d4d4f..3bc2ef9 100644 --- a/helpers.php +++ b/helpers.php @@ -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; @@ -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 @@ -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; }