Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
back
/
app
/
Services
:
ResponseService.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php declare(strict_types=1); namespace App\Services; use App\Responses\ResponseDto; use Illuminate\Http\JsonResponse; class ResponseService { public static function json($result = null, $status = 200): JsonResponse { try { return response()->json(self::wrap($result), $status); } catch (\Throwable $exception) { dd($exception); } } public static function array($result = null, bool $paginatable = false): array { try { return self::wrap($result, $paginatable)->toArray(); } catch (\Throwable $exception) { dd($exception); } } public static function wrap(array $result = null, ?bool $paginatable = false): ResponseDto { return ResponseDto::from([...$result, 'paginatable' => $paginatable]); } }