jeudi 6 décembre 2018

Laravel - Message Toastr, on Error or Invalid Input Fields

Hello I have this message notification when I add, edit, and delete but when the error on the field for example, i leave the textbox empty then the error will pop up but the error is not a toast it is a div class="alert alert-danger> can you help me on how to convert this into toastr?

here is my error on messages.blade.php

@if(count($errors) > 0)
    @foreach($errors->all() as $error)
        <div class="alert alert-danger">
            
        </div>
     @endforeach
@endif

I have this tostr working on my scripts and success , info are working prettty well, but the error as i said is not working

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>

<script>
          @if(Session::has('message'))
        var type=""

        switch(type){
            case 'info':
                 toastr.info("");
                 break;
            case 'success':
                toastr.success("");
                break;
            case 'warning':
                toastr.warning("");
                break;
            case 'error':
                toastr.error("");
                break;
        }
      @endif
</script>

my controller

here is where i return my view when the page is successfully created

 $notification = array(
        'message' => 'Employee Information Created!',
        'alert-type' => 'success'
    );

    return redirect('/admin/employeemaintenance/show')->with( $notification, 'Employee Information Created');

anyone knows how to solve this one? thanks in advanced



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Um6R8q
via IFTTT

Aucun commentaire:

Enregistrer un commentaire