KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /var/www/demo.aadityaguptaclasses.com/app/Api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/demo.aadityaguptaclasses.com/app/Api/ApiResponseBuilderTrait.php
<?php

namespace App\Api;

trait ApiResponseBuilderTrait
{
    public $retrievedStatus = 'retrieved';
    public $updatedStatus = 'updated';
    public $deletedStatus = 'deleted';
    public $storedStatus = 'stored';
    public $notFoundStatus = 'not_found';
    public $validationError = 'validation_error';
    public $invalidContentType = 'invalid_content_type';

    public function success($message, $data = [], $status_code = 200)
    {
        return response()->json([
            'success' => true,
            'status' => $status_code,
            'message' => $message,
            'data' => $data
        ], $status_code);
    }


    public function failure($message, $status_code = 401, $custom_status = null)
    {
        return response()->json([
            'success' => false,
            'status' => $custom_status ?: $status_code,
            'message' => $message,
        ], $status_code);
    }

    public function notFound()
    {
        return $this->failure(trans('http_status.404'), 404);
    }

    public function forbidden()
    {
        return $this->failure(trans('http_status.403'), 403);
    }

    public function failureWithErrors($message, $status, $data, $status_code = 401)
    {
        return response()->json([
            'success' => false,
            'status' => $status,
            'message' => $message,
            'data' => $data,
        ], $status_code);
    }
}

Anon7 - 2021