Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Illuminate/Support/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Dumpable;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\Traits\Tappable;
use League\Uri\Contracts\UriInterface;
use League\Uri\Uri as LeagueUri;
Expand All @@ -17,7 +18,7 @@

class Uri implements Htmlable, Responsable, Stringable
{
use Conditionable, Dumpable, Tappable;
use Conditionable, Dumpable, Macroable, Tappable;

/**
* The URI instance.
Expand Down
11 changes: 11 additions & 0 deletions tests/Support/SupportUriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,15 @@ public function test_path_segments()

$this->assertEquals(3, $uri->pathSegments()->count());
}

public function test_macroable()
{
Uri::macro('myMacro', function () {
return $this->withPath('foobar');
});

$uri = new Uri('https://laravel.com/');

$this->assertSame('https://laravel.com/foobar', (string) $uri->myMacro());
}
}
Loading