PHP Classes

File: server/app/Http/Controllers/Controller.php

Recommend this page to a friend!
  Classes of mohammad anzawi   PHP Wallet API and Application   server/app/Http/Controllers/Controller.php   Download  
File: server/app/Http/Controllers/Controller.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Wallet API and Application
Application to manage a wallet by calling an API
Author: By
Last change:
Date: 2 years ago
Size: 960 bytes
 

Contents

Class file image Download
<?php

namespace App\Http\Controllers;

use
Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use
Illuminate\Foundation\Bus\DispatchesJobs;
use
Illuminate\Foundation\Validation\ValidatesRequests;
use
Illuminate\Routing\Controller as BaseController;

class
Controller extends BaseController
{
    use
AuthorizesRequests, DispatchesJobs, ValidatesRequests;

   
/**
     * success response method.
     *
     * @return \Illuminate\Http\JsonResponse
     */

   
public function sendResponse(array $result, string $message = '')
    {
       
$response = [
           
'success' => true,
           
'data' => $result,
           
'message' => $message,
        ];


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

   
/**
     * return error response.
     *
     * @return \Illuminate\Http\JsonResponse
     */
   
public function sendError($errorMessages = [], $code = 404)
    {
        return
response()->json($errorMessages, $code);
    }
}