<?php
namespace App\Traits;

trait JsonResponseTrait
{
    /**
     * @param array $data
     * @return \Illuminate\Http\JsonResponse
     */
    public function success($data = [])
    {
        return response()->json([
            'status' => 'success',
            'data' => $data
        ]);
    }
    
    /**
     * @param string $message
     * @return \Illuminate\Http\JsonResponse
     */
    public function error($message = '', $status = 200)
    {
        return response()->json([
            'status' => 'error',
            'message' => $message
        ], $status);
    }

}