Laravel - URL Generation - Generating Urls

The url helper 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 being handled by the application:

    
    $post = App\Models\Post::find(1);
    
    echo url("/posts/{$post->id}");
    
    // http://example.com/posts/1