Skip to content

Commit 726b1e0

Browse files
authored
Merge pull request #205 from binotaliu/macroable
Make Response macroable
2 parents f802df2 + 8b9a8d0 commit 726b1e0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Response.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
use Illuminate\Support\Arr;
1010
use Illuminate\Support\Facades\App;
1111
use Illuminate\Support\Facades\Response as ResponseFactory;
12+
use Illuminate\Support\Traits\Macroable;
1213

1314
class Response implements Responsable
1415
{
16+
use Macroable;
17+
1518
protected $component;
1619
protected $props;
1720
protected $rootView;

tests/ResponseTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
class ResponseTest extends TestCase
1919
{
20+
public function test_can_macro()
21+
{
22+
$response = new Response('User/Edit', []);
23+
$response->macro('foo', function () {
24+
return 'bar';
25+
});
26+
27+
$this->assertEquals('bar', $response->foo());
28+
}
29+
2030
public function test_server_response()
2131
{
2232
$request = Request::create('/user/123', 'GET');

0 commit comments

Comments
 (0)