我有如下所示的API输出
"id": 1,
"employee_id": 1,
"text": "good",
"employee": "Jamal"
我的查询如下所示
return $company
->employee()
->with('motorcycle', 'children')
->join('shop', function ($join) {
$join->on('shop.shop_id', '=', 'attendence.shop_id');
$join->on('shop.employee_id', '=', 'residence.employee_id');
})
->get();
我想得到如下输出
"company": {
"id": 1,
"employee_id": 1,
"text": "good",
"employee": "Jamal"
}
答案 0 :(得分:0)
这是我的api.php 它将首先验证您的数据,然后如您所述提供输出。
Route::get('articles', function() {
$articles = article::all();
if(count($articles) == 0){
$feedback = [
'status' => "error",
'message' => "data not found",
'company' => null
];
}else{
$articles = [
'status' => "success",
'message' => "data found",
'company' => $articles
];
}
return $articles;
});