Skip to content

Commit 4c9f506

Browse files
committed
refactor: make minor changes for interface changes in 4.x
1 parent 9447c84 commit 4c9f506

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"ext-json": "*",
2828
"illuminate/database": "^10.0",
2929
"illuminate/support": "^10.0",
30-
"laravel-json-api/core": "^3.0"
30+
"laravel-json-api/core": "^4.0"
3131
},
3232
"require-dev": {
3333
"orchestra/testbench": "^8.0",
@@ -51,7 +51,7 @@
5151
"dev-4.x": "4.x-dev"
5252
}
5353
},
54-
"minimum-stability": "stable",
54+
"minimum-stability": "dev",
5555
"prefer-stable": true,
5656
"config": {
5757
"sort-packages": true

src/HasQueryParameters.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ trait HasQueryParameters
4040
/**
4141
* @inheritDoc
4242
*/
43-
public function withRequest(Request $request): BuilderContract
43+
public function withRequest(?Request $request): BuilderContract
4444
{
45-
$this->request = $request;
46-
$this->queryParameters = ExtendedQueryParameters::cast($request);
45+
if ($request) {
46+
$this->request = $request;
47+
$this->queryParameters = ExtendedQueryParameters::cast($request);
48+
}
4749

4850
return $this;
4951
}

src/Hydrators/ModelHydrator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use Illuminate\Database\Eloquent\Model;
2323
use Illuminate\Support\Collection;
24+
use Illuminate\Support\ValidatedInput;
2425
use LaravelJsonApi\Contracts\Schema\Attribute;
2526
use LaravelJsonApi\Contracts\Schema\Field;
2627
use LaravelJsonApi\Contracts\Schema\Relation as RelationContract;
@@ -87,9 +88,13 @@ public function __construct(
8788
/**
8889
* @inheritDoc
8990
*/
90-
public function store(array $validatedData): object
91+
public function store(ValidatedInput|array $input): object
9192
{
92-
$model = $this->hydrate($validatedData);
93+
if ($input instanceof ValidatedInput) {
94+
$input = $input->all();
95+
}
96+
97+
$model = $this->hydrate($input);
9398

9499
/**
95100
* Always refresh the model from the database.

0 commit comments

Comments
 (0)