How to Generate Dynamic URL in Laravel 10?




How to Generate Dynamic URL in Laravel 10?

Hi Guys,

This article will provide some of the most important examples of how to generate a dynamic URL In Laravel 10. I’m going to show you how to create a dynamic URL in Laravel 10. if you want to see an example of a dynamic URL in Laravel 10 then you are in the right place. We will use how to make a dynamic URL in Laravel 10.

Today, In this tutorial I will explain you to how to get generate a dynamic URL in Laravel 10. if you don't know how to how to generate A dynamic URL in Laravel 10. So don't worry I will tell you that Laravel 10 provides a URL helper that may be used to generate arbitrary URLs for your application. The generated URL will automatically use the scheme (HTTP or HTTPS) and host from the current request.

Here, I will give you a full example of Laravel 10 generating URL in the controller so follow my all steps.

Download Laravel

Let us begin the tutorial by installing a new Laravel application. if you have already created the project, then skip the following step.

composer create-project laravel/laravel example-app



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\Product;

class TestController extends Controller



* Write Your Code...


* @return string


public function index()


$product = Product::find(1);






Get Current URL:

If no path is provided to the URL helper, an Illuminate\Routing\UrlGenerator instance is returned, sanctioning you to access information about the current URL:

// Get the current URL without the query string...

echo url()->current();

// Get the current URL including the query string...

echo url()->full();

// Get the full URL for the previous request...

echo url()->previous();

So, you can generate these methods that may also be accessed via the URL facade:

use Illuminate\Support\Facades\URL;

echo URL::current();

It will help you...

#Laravel 10