the following is the controller of the API interface I wrote:
<?php
namespace App\Http\Controllers\Lucky;
use Illuminate\Http\Request;
use App\Http\Controllers\BaseController as BaseController;
use App\Models\Card;
use App\Http\Transformers\CardsTransformer;
class CardsController extends BaseController
{
public function test(Request $request) {
$unionId = $request->input("unionId");
$card = new Card;
$card->union_id = $unionId;
$card->fi_card = 1;
$card->s_card = 2;
$card->t_card = 3;
$card->fo_card = 4;
$card->save();
return $this->response->item($card, new CardsTransformer());
}
}
write like this. The return body obtained by calling this API is as follows:
{
"data": {
"unionId": "test",
"fiCard": 1,
"sCard": 2,
"tCard": 3,
"foCard": 4
}
}
but I think the correct return body of the API interface should be as follows:
{
code:0,
message:"ok",
data:{},
useTime:0.017374038696289062
}
how do I configure code
and message
fields for the return body of each interface in the technology stack of laravel and dingo/api? And its corresponding content?