Skip to content

Commit 10c5a42

Browse files
authored
Merge pull request #91 from inertiajs/macroable
Make response factory macroable
2 parents f076557 + 7f2dfcb commit 10c5a42

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: src/ResponseFactory.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
use Closure;
66
use Illuminate\Support\Arr;
77
use Illuminate\Support\Facades\App;
8+
use Illuminate\Support\Traits\Macroable;
89
use Illuminate\Contracts\Support\Arrayable;
910

1011
class ResponseFactory
1112
{
13+
use Macroable;
14+
1215
protected $rootView = 'app';
1316
protected $sharedProps = [];
1417
protected $version = null;

Diff for: tests/ResponseFactoryTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Inertia\Tests;
4+
5+
use Inertia\ResponseFactory;
6+
7+
class ResponseFactoryTest extends TestCase
8+
{
9+
public function test_can_macro()
10+
{
11+
$factory = new ResponseFactory();
12+
$factory->macro('foo', function () {
13+
return 'bar';
14+
});
15+
16+
$this->assertEquals('bar', $factory->foo());
17+
}
18+
}

0 commit comments

Comments
 (0)