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/Response.php
<?php

namespace App\Api;

class Response
{
    private $status;
    private $data;
    private $msg;
    private $success;

    public function apiResponse($success, $msg = null, $data = null, $http_status = null)
    {
        $this->success = $success;
        $this->msg = $msg;

        $this->data = $data;
        $json = ['message' => $msg, 'success' => $this->getSuccess()];
        if (isset($data)) {
            $json['data'] = $data;
        }

        return response()->json($json);
    }

    public function apiResponse2($success, $status, $msg, $data = null,$title=null)
    {
        $this->success = $success;
        $this->msg = $msg;
        $this->status = $status;

        $this->data = $data;
        $json = ['success' => $this->getSuccess(), 'status' => $this->getStatus(), 'message' => $this->getMsg()];

        if (isset($title)) {
            $json['title'] = $title;
        }

        if (isset($data)) {
            $json['data'] = $data;
        }

        return response()->json($json);
    }


    public function returnData($data)
    {
        return ['count' => $data->count(), 'data' => $data];
    }

    public function getStatus()
    {
        switch ($this->status) {
            case 'list':
                return 'list';
            case 'passed' :
                return 'passed';
            case 'max-attempt' :
                return 'max-attempt';
            case 'validation_error' :
                return 'validation_error' ;
            case "no_meeting":
                return 'no_meeting' ;
            case "disabled":
                return 'disabled' ;
            case "invalid":
                return 'invalid' ;
            default:
                return $this->status ;


        }
    }


    public function getSuccess()
    {
        switch ($this->success) {
            case 1:
                return true;
            case 0 :
                return false;
        }
    }

    public function getMsg()
    {
        if (!$this->msg) {
            switch ($this->getSuccess()) {
                case 'list':
                    return 'data reitrived successfully';
                case 0 :
                    return 'failed';
            }
        }
        return $this->msg;

    }
}

Anon7 - 2021