Skip to content
Advertisement

How to add a link to route to another page in laravel

I have a view page which i need to add a link to redirect the user to a booking page. I’m not so familiar with PHP so any guides would be helpful.

  <td>
  @if ($place->status==0)
    <span> Available </span>
  @endif
  @if ($place->status==-1)
    <span> Not Available </span>
  @endif
  @if ($place->status==2)
    <span> Booked </span>
  @endif
 </td> 

This is the table i have, and i need to add a link next to the of Available to redirect to another page called “quickbookingmodal.blade.php”. This file is basically a pop up menu to add bookings into the system.

Advertisement

Answer

Hi. You can do this :

@if ($place->status==0)
   <a href="{{ route ('quickbookingmodal')}}">Available</a>
@endif

In your file route :

Route::get('/quickbookingmodal','bookingController@index')->name('quickbookingmodal')

Make sure you got an bookingController with :

function index() {
    return view ('/quickbookingmodal')
}
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement