File manager - Edit - /var/www/html/pcadigital/api/app/Helpers/helpers.php
Back
<?php use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; if (!function_exists('paginate')) { function paginate($items, $perPage = 10, $page = null, $options = []) { $page = $page ?: (Paginator::resolveCurrentPage() ?: 1); $items = $items instanceof Collection ? $items : Collection::make($items); return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options); } } if (!function_exists('isBase64')) { function isBase64($content): bool { $first = substr($content, 0, 4); if ($first == "data") { return true; } return false; } } if (! function_exists('authServiceClient')) { function authServiceClient(string $method, string $url, Request|array|null $request = null, array $headers = []) { $bearerToken = isset($request) && $request instanceof Request && !empty($request->bearerToken()) ? 'Bearer ' . $request->bearerToken() : null; $httpClient = Http::withHeaders([ 'Accept' => 'application/json', 'Authorization' => $bearerToken, 'App' => env('CLIENT_APP_KEY'), ...$headers ]); switch(strtoupper($method)) { case 'GET': return $httpClient->get($url); case 'POST': return $httpClient->post($url, $request); case 'PUT': return $httpClient->put($url, $request); case 'PATCH': return $httpClient->patch($url, $request); case "DELETE": return $httpClient->delete($url); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings