I successfully save data in the database. However, the data can't be found after saving.
In the JSON,the key object's value is an empty array. My object model:
protected $table = 'objects';
public $timestamps = false;
protected $primaryKey = 'object_id';
public $incrementing = false;
protected $fillable = ['object_id','object_lt_x', 'object_lt_y', 'object_width', 'object_height', 'image_id', 'type_id'];
Save the data to database
$obj = new Object;
$obj->object_id = $objectId;
$obj->object_lt_x = $objX;
$obj->object_lt_y = $objY;
$obj->object_width = $objWidth;
$obj->object_height = $objHeight;
$obj->image_id = $imageId;
$obj->type_id = $typeId;
if ($obj->save()) {
$obj_id = $obj->object_id;
$object = DB::table('objects')->where('object_id',$objectId)->get();
$success = array('status' => 1,'message' => $type_name.'标记成功!','obj_id' => $obj_id,'object' => $object);
return response()->json($success);
} else {
$error = array('status' => 0,'message' => $type_name.'标记失败!');
return response()->json($error);
}
The result is:
Object {status: 1, message: "眼睛标记成功!", obj_id: "A7313004-3B7D-56F2-602F-FC81D4A8F04F", object: Array[0]}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire