| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Models\DTO\Toss;
- use Illuminate\Contracts\Support\Responsable;
- use Illuminate\Http\JsonResponse;
- class FailData implements Responsable
- {
- public string $resultType;
- public ?array $error;
- public ?array $success;
- public function __construct(string $errorCode, string $reason)
- {
- $this->resultType = 'FAIL';
- $this->error = [
- 'errorCode' => $errorCode,
- 'reason' => $reason
- ];
- $this->success = null;
- }
- public function __set($name, $value)
- {
- $this->{$name} = $value;
- }
- public function __get($name): mixed
- {
- return ($this->{$name} ?? null);
- }
- public function toResponse($request): JsonResponse
- {
- return response()->json($this);
- }
- }
|