@@ -18,9 +18,9 @@ the package's error class. All the keys described in the specification's
18
18
For example:
19
19
20
20
``` php
21
- use CloudCreativity\LaravelJsonApi\Document\Error;
21
+ use CloudCreativity\LaravelJsonApi\Document\Error\Error ;
22
22
23
- $error = Error::create ([
23
+ $error = Error::fromArray ([
24
24
'id' => '91053382-7c00-45eb-bdcc-8359d03debbb',
25
25
'status' => '500',
26
26
'code' => 'unexpected',
@@ -40,15 +40,16 @@ The `JsonApiController` has a responses factory that can create error responses.
40
40
to return an error response in a controller hook, as demonstrated in the following example:
41
41
42
42
``` php
43
- use CloudCreativity\LaravelJsonApi\Document\Error;
43
+ use CloudCreativity\LaravelJsonApi\Document\Error\Error;
44
+ use CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController;
44
45
45
46
class PaymentController extends JsonApiController
46
47
{
47
48
48
49
protected function creating()
49
50
{
50
51
if (/** some condition */) {
51
- return $this->reply()->errors(Error::create ([
52
+ return $this->reply()->errors(Error::fromArray ([
52
53
'title' => 'Payment Required',
53
54
'detail' => 'Your card has expired.',
54
55
'status' => '402',
@@ -85,12 +86,12 @@ to a JSON API response. For example:
85
86
86
87
``` php
87
88
use Neomerx\JsonApi\Exceptions\JsonApiException;
88
- use CloudCreativity\LaravelJsonApi\Document\Error;
89
+ use CloudCreativity\LaravelJsonApi\Document\Error\Error ;
89
90
90
91
try {
91
92
dispatchNow(new ChargeCard($token));
92
93
} catch (\App\PaymentException $ex) {
93
- $error = Error::create ([
94
+ $error = Error::fromArray ([
94
95
'title' => 'Payment Required',
95
96
'detail' => $ex->getMessage(),
96
97
'status' => '402',
0 commit comments