Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ts.corals.io/corals-api/Corals/core/Foundation/Helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/core/Foundation/Helpers/api_helpers.php
<?php

use Illuminate\Validation\ValidationException;

if (!function_exists('apiPluck')) {
    /**
     * @param $array
     * @param string $keyLabel
     * @param string $valueLabel
     * @return array
     */
    function apiPluck($array, $keyLabel = 'key', $valueLabel = 'value')
    {
        if ($array instanceof \Illuminate\Support\Collection) {
            $array = $array->toArray();
        } elseif (!is_array($array)) {
            return [];
        }

        $result = [];

        foreach ($array as $key => $value) {
            $result[] = [$keyLabel => $key, $valueLabel => $value];
        }

        return $result;
    }
}

if (!function_exists('apiResponse')) {
    /**
     * @param $data
     * @param string $message
     * @param string $status
     * @param int $HttpStatus
     * @param array $headers
     * @param int $options
     * @return \Illuminate\Http\JsonResponse
     */
    function apiResponse($data, $message = '', $status = 'success', $HttpStatus = 200, $headers = [], $options = 0)
    {
        return response()->json([
            'status' => $status,
            'message' => strip_tags($message),
            'data' => $data,
        ], $HttpStatus, $headers, $options);
    }
}
if (!function_exists('apiExceptionResponse')) {
    /**
     * @param $exception
     * @param array $data
     * @return \Illuminate\Http\JsonResponse
     */
    function apiExceptionResponse($exception, $data = [])
    {
        logger(array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2), -1));

        report($exception);

        if ($exception instanceof ValidationException) {
            return apiResponse(['errors' => $exception->validator->getMessageBag()],
                trans('validation.message'), 'error', 422);
        }

        return apiResponse(array_merge(['exception_code' => $exception->getCode()], $data),
            strip_tags($exception->getMessage()), 'error', 400);
    }
}

Spamworldpro Mini