-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f60d5b6
commit eb17eb5
Showing
6 changed files
with
38 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the jiannei/laravel-response. | ||
* | ||
* (c) Jiannei <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Jiannei\Response\Laravel\Contracts; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
@@ -13,7 +22,7 @@ interface Format | |
* | ||
* @param array|null $data | ||
* @param string|null $message | ||
* @param int $code | ||
* @param int $code | ||
* @param null $errors | ||
* @return array | ||
*/ | ||
|
@@ -37,7 +46,7 @@ public function statusCode($code): int; | |
* @param int $option | ||
* @return array | ||
*/ | ||
public function paginator(AbstractPaginator $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0):array; | ||
public function paginator(AbstractPaginator $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0): array; | ||
|
||
/** | ||
* Format collection resource data. | ||
|
@@ -62,4 +71,4 @@ public function resourceCollection(ResourceCollection $resource, string $message | |
* @return array | ||
*/ | ||
public function jsonResource(JsonResource $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0): array; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the jiannei/laravel-response. | ||
* | ||
* (c) Jiannei <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Jiannei\Response\Laravel\Tests; | ||
|
||
use Jiannei\Response\Laravel\Support\Facades\Response; | ||
|
@@ -12,7 +21,7 @@ public function testAddExtraField() | |
|
||
$this->assertEquals(200, $response->status()); | ||
|
||
$this->assertArrayHasKey('extra',$response->getData(true)); | ||
$this->assertArrayHasKey('time',$response->getData(true)['extra']); | ||
$this->assertArrayHasKey('extra', $response->getData(true)); | ||
$this->assertArrayHasKey('time', $response->getData(true)['extra']); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the jiannei/laravel-response. | ||
* | ||
* (c) Jiannei <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Jiannei\Response\Laravel\Tests\Support; | ||
|
||
use Illuminate\Support\Facades\Config; | ||
|
@@ -19,8 +28,8 @@ public function data(?array $data, ?string $message, int $code, $errors = null): | |
'data' => $data ?: (object) $data, | ||
'error' => $errors ?: (object) [], | ||
'extra' => [ | ||
'time' => time() | ||
'time' => time(), | ||
], | ||
], Config::get('response.format.fields', [])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters