Mathieu Mourareau
Mathieu Mourareau

Reputation: 1220

Laravel redirect route with link in the view

I try to show a button in my view when a new licence is create on my store controller . Everything is fine till i want to display a link or a button to the view .

here my controller

public function store(LicencieProCreateRequest $request){
//
..
 return redirect('home')->with('status', "La Licence Pro pour : " . $licencie_pro->lb_nom . " à bien été crée ! " . route('licencie-joueur-pro.show', 'Voir la licence', [$licencie_pro->id], ['class' => 'btn btn-default']) );

}

here my view Blade who display the notification with the URL but i would like a link or a button is it possible ?

@if (session('status')) 
    <div class="alert alert-success">
      {{ session('status') }}
    </div>
  @endif

Upvotes: 3

Views: 779

Answers (1)

Sanzeeb Aryal
Sanzeeb Aryal

Reputation: 3266

You can pass status as variable:

return redirect('home')->with(['status'=>$status]);

and link to anywhere when clicking on the status:

@if ($status) 
    <div class="alert alert-success">
      <a href="{{url('/')}}">{{$status}}</a>
    </div>
@endif

Upvotes: 1

Related Questions