G
G
Givi7772019-08-05 13:34:36
Laravel
Givi777, 2019-08-05 13:34:36

Why are Laravel sessions not working?

controller

if ($company == null) {
        return redirect()->back()->with('error', ['Внимание! ...']);
    }

view
@if(session()->has('error'))
       <div class="alert alert-danger alert-dismissable">
          <a href="#" class="close" data-dismiss="alert" aria-label="close">x</a>
          {{ session()->get('error') }}
    </div>
    @endif

Just a page refresh happens
ps

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Sannikov, 2019-08-17
@k-sannikow

// First option

{{-- Вывод списка ошибок --}}
@if(!is_null($errors->all()))
    @foreach($errors->all() as $error)
        <div class="row justify-content-center">
            <div class="col-md-11">
                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                    {{ $error }}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            </div>
        </div>
    @endforeach
@endif

// Second variant
{{-- Вывод списка ошибок--}}
@if(!is_null(session('errors')))
    @foreach(session('errors') as $error)
        <div class="row justify-content-center">
            <div class="col-md-11">
                <div class="alert alert-success alert-dismissible fade show" role="alert">
                    {{ $error}}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            </div>
        </div>
    @endforeach
@endif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question