You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
425 B
22 lines
425 B
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
trait ApiResponse
|
|
{
|
|
public function success($data)
|
|
{
|
|
if (gettype($data) == "string") {
|
|
$data = ["msg" => $data];
|
|
}
|
|
return response()->json($data);
|
|
}
|
|
|
|
public function fail(array $responseCode)
|
|
{
|
|
$errcode = $responseCode[0];
|
|
$errmsg = $responseCode[1];
|
|
return response()->json(compact("errcode", "errmsg"));
|
|
}
|
|
}
|