Skip to content

Commit 269207e

Browse files
committed
wip
1 parent 46d5ebd commit 269207e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1659
-777
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ Define an [attribute field](https://jsonapi.org/format/#document-resource-object
101101
$schema->attribute('firstName');
102102
```
103103

104-
By default the attribute will correspond to the property on your model with the same name. (`EloquentAdapter` will `snake_case` it automatically for you.) If you'd like it to correspond to a different property, provide it as a second argument:
104+
By default the attribute will correspond to the property on your model with the same name. (`EloquentAdapter` will `snake_case` it automatically for you.) If you'd like it to correspond to a different property, use the `property` method:
105105

106106
```php
107-
$schema->attribute('firstName', 'fname');
107+
$schema->attribute('firstName')->property('fname');
108108
```
109109

110110
### Relationships
@@ -122,7 +122,7 @@ By default the [resource type](https://jsonapi.org/format/#document-resource-obj
122122
$schema->hasOne('author')->type('people');
123123
```
124124

125-
Like attributes, the relationship will automatically read and write to the relation on your model with the same name. If you'd like it to correspond to a different relation, provide it as a third argument.
125+
Like attributes, the relationship will automatically read and write to the relation on your model with the same name. If you'd like it to correspond to a different relation, use the `property` method.
126126

127127
#### Relationship Links
128128

@@ -315,7 +315,7 @@ $schema->attribute('firstName')
315315
});
316316
```
317317

318-
If your attribute corresponds to some other form of data storage rather than a simple property on your model, you can use the `save` method to provide a closure to be run _after_ your model is saved:
318+
If your field corresponds to some other form of data storage rather than a simple property on your model, you can use the `save` method to provide a closure to be run _after_ your model is saved:
319319

320320
```php
321321
$schema->attribute('locale')

src/Adapter/EloquentAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function getHasOneId($model, HasOne $relationship): ?string
7474
$relation = $this->getRelation($model, $relationship);
7575

7676
// If this is a belongs-to relation, we can simply return the value of
77-
// the foreign key on the model.
77+
// the foreign key on the model. Otherwise we will have to fetch the
78+
// full related model and return its key.
7879
if ($relation instanceof BelongsTo) {
7980
return $model->{$relation->getForeignKeyName()};
8081
}

src/Handler/Concerns/IncludesData.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use function Tobyz\JsonApiServer\evaluate;
88
use Tobyz\JsonApiServer\Exception\BadRequestException;
99
use Tobyz\JsonApiServer\ResourceType;
10-
use Tobyz\JsonApiServer\Schema\HasMany;
1110
use Tobyz\JsonApiServer\Schema\Relationship;
1211

1312
trait IncludesData

src/JsonApiResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class JsonApiResponse extends JsonResponse
88
{
99
public function __construct(
1010
$data,
11-
$status = 200,
11+
int $status = 200,
1212
array $headers = [],
13-
$encodingOptions = self::DEFAULT_JSON_FLAGS
13+
int $encodingOptions = self::DEFAULT_JSON_FLAGS
1414
) {
1515
$headers['content-type'] = JsonApi::CONTENT_TYPE;
1616

src/Schema/Field.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,4 @@ public function getFilterable()
166166
{
167167
return $this->filterable;
168168
}
169-
170-
171169
}

src/Schema/Relationship.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function loadable(Closure $callback = null)
4848
return $this;
4949
}
5050

51-
public function notLoadable()
52-
{
53-
$this->loadable = false;
54-
55-
return $this;
56-
}
51+
// public function notLoadable()
52+
// {
53+
// $this->loadable = false;
54+
//
55+
// return $this;
56+
// }
5757

5858
public function includable()
5959
{

src/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Tobyz\JsonApiServer\Schema\Attribute;
1818
use Tobyz\JsonApiServer\Schema\Relationship;
1919

20-
class Serializer
20+
final class Serializer
2121
{
2222
protected $api;
2323
protected $request;

tests/feature/AttributeFilterableTest.php

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)