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

errors.blade.php may fail if there is no errors array #6

Open
ghost opened this issue Oct 3, 2018 · 0 comments
Open

errors.blade.php may fail if there is no errors array #6

ghost opened this issue Oct 3, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 3, 2018

I discovered that when there is only one error in error array, then error.blade.php code may fail to run.
Suggestion to improve the code is added below:

@if (isset($errors))
    @if(is_array($errors))
        @if( count($errors) > 0)
            <div class="alert alert-dismissable alert-danger fade show">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                @foreach($errors->all() as $error)
                    <li class="list-unstyled"><strong>{!! $error !!}</strong></li>
                @endforeach
            </div>
        @endif
    @else
        <div class="alert alert-dismissable alert-danger fade show">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            <li class="list-unstyled"><strong>{{$errors}}</strong></li>
        </div>
    @endif
@endif
@ghost ghost changed the title errors.partials.php may fail if there is no errors array errors.blade.php may fail if there is no errors array Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants