Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MahmoudAdelAli's avatar

Best practice to show get messages

Hi , i know this is traditional question but may there's better way to do it , when we move the user from page to another with message like ?success=done , if the user write it at the link the message 'll visible cause we do it at blade like

  @if(request()->has('subscription') == 'stopped')
                <div class="alert alert-danger">
                {{__('subscription_stopped')}}
                </div>
            @endif

so there's solutions like session etc .. what's best practice to do that ?

0 likes
2 replies
PovilasKorop's avatar

I know this topic already has the Best Answer but wanted to point out that you don't need to flash manually, just use with():

public function store(Request $request) {
    // ...
 
    return redirect()->route('tasks.index')
        ->with('message', 'Record added successfully!');
}
1 like

Please or to participate in this conversation.