i want to make Api in there i want to show 2 table in this Api. but i get trouble in there :
this my Api Controller :
public function postDetaillog(Request $request){
$response = array();
$validator = Validator::make($request->all(),
[
'id'=> 'required',
]
);
if ($validator->fails())
{
$message = $validator->errors()->all();
$result['api_status'] = 0;
$result['api_message'] = implode(', ',$message);
$res = response()->json($result);
$res->send();
exit;
}
$data = DB::table('log_patrols')
->where('id', $request->input('id'))
->first();
$site = asset("uploads").'/';
$result= DB::table('log_patrol_details')
->select("*",DB::raw("concat('$site',photo1) as photo1"),DB::raw("concat('$site',photo2) as photo2"),DB::raw("concat('$site',photo3) as photo3"))
->where('id', $request->input('id'))
->first();
if(count($result)==0) {
$response['api_status'] = count($result);
$response['api_message'] = "No data";
}else{
$response['api_status'] = 1;
$response['api_message'] = "success";
$response['data'] = $data;
$response['result'] = $result;
}
return response()->json($response);
}
when ever i try to get the result, the result always get 0 = no data
have someone give me solution for me ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire