#How to correctly manage routing in case: -come back to main ('/') and then to the specific view.

16 messages · Page 1 of 1 (latest)

tidal elm
#

What exactly are you asking? The documentation on routing provides plenty of examples. The default Laravel installation also provides you with a GET route for / that displays a view (welcome)

nova frigate
#

sure ,let me explain

#

<?php
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
return view('welcome');
});

Route::get('/v/index', [\App\Http\Controllers\menu_controller::class, 'index_window']);
Route::get('/v/contact/index', [\App\Http\Controllers\menu_controller::class, 'contact_window']);

#

Route::get('/services/index', [\App\Http\Controllers\menu_controller::class, 'services_window']);

#

if i go to one link ,and thant click again it just says page not found,because it adds again to link /v/index ,ex: /v/index/v/index

tidal elm
#

That has nothing to do with your routes, but more with the anchor links in your view.

#

You could name your routes, and then use the route helper to properly link. For example:

#
Route::get('/v/index', [\App\Http\Controllers\menu_controller::class, 'index_window'])->name('window.index');
nova frigate
#

or if i go to services link for example , and go then to contact it will give link /services_window/contact/index

tidal elm
#
<a href="{{ route('window.index') }}">Some link</a>
nova frigate
#

ok !

tidal elm
nova frigate
#

i see

proper escarp
#

Relative vs absolute URLs, you're using links like v/index, which the browser just appends to the current URL. You'd want to use absolute paths, like /v/index

nova frigate
#

yep ,because in my div i have this : <div id="menu"><a href="/services/index">services </a></div>

nova frigate
#

it works just perfect gentelmans !