init
This commit is contained in:
232 files changed
+25416
No files matched your search
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\CafeBazaar;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class BazaarResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $status,
|
||||
public readonly array $body,
|
||||
) {}
|
||||
|
||||
public function successful(): bool
|
||||
{
|
||||
return $this->status >= 200 && $this->status < 300;
|
||||
}
|
||||
|
||||
public function toJsonResponse(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => $this->successful() ? $this->body : null,
|
||||
'error' => $this->successful() ? null : $this->body,
|
||||
'meta' => ['bazaar_status' => $this->status],
|
||||
], $this->status);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user