How do you put a message after a successful action on laravel?



  • How long has it been since you started studying laravel and the question arose how after the challenge of the method in the counteraller to return any message?

    $this->session->set_flashdata('msg', '<div class="alert alert-success text-left">' . $this->lang->line('success_message') . '</div>');
       $this->load->view('test', $data);



  • Simpleest and verified version

    To report on the success of the operation:

    In contrast

    return redirect()->route('ваш_роут')->with('success', 'урааа');
    

    Blade.

    @if (session('success'))
        {{ session('success') }}
    @endif
    

    To report the error:

    In contrast

    return redirect()->route('ваш_роут')->withError('нееееет');
    

    It's situational. For example, in lieu of recirculation and rolling, the back(s) may be added, or at all, the user &apos; s port through withInputs().

    Blade.

    @if($errors->any())
        @foreach($errors->all() as $error)
            {{ $error }}
        @endforeach
    @endif
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2