Skip to main content

Posts

Showing posts with the label laravel generate urls to named routes

Laravel Generate URLs to Named Routes Tutorial

Hi Guys, In this blog, i will give you simaple example of generate urls to named routes in laravel. we are create examples of url to named route. All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by the framework. The routes/web.php file defines routes that are for your web interface. Example 1: Basic Url To Routes Laravel provides a global route() function that gets the URL to a named route. The only one Parameter is the route name (string). Simple example, it would look as routes/web.php file defines routes that are for your web interface: Basic Route: <?php use App\Http\Controllers\HomeController; Route::get('Home', ['HomeController::class','index'])->name('home'); or This is achieved by chaining the name() method to the route definition: Route::get('Home', function() { return view('home'); })->name('home'); Simple example, as