how to return with open modal popup in laravel code example

Example: how to return with open model popup in laravel

//pass back a variable when redirecting
return Redirect::back()->with('error_code', 5);

//in blade tempalte
@if(!empty(Session::get('error_code')) && Session::get('error_code') == 5)
<script>
$(function() {
    $('#myModal').modal('show');
});
</script>
@endif
  
//second seneario use like this
  <script type="text/javascript">
    @if(!empty(Session::get('error_code')))
        <?php $a = Session::get('error_code'); ?>
        $('#updateCarModel{{ $a }}').modal('show');
        console.log("#updateCarModel{{ $a }}");
    @endif
</script>
//@sujay

Tags:

Php Example