I made an application which is providing data to my mobile devices via rest api. I am having data coming from various tables based on the relations established between them via keys(Foreign/Index).
I am using ActiveDataProvider to extract required data from tables.
$dataProvider = new ActiveDataProvider([
'query'=>$query
]);
This is working great based on the query I set and returning data in JSON format as I needed when I return it as follows:
return $dataProvider;
What I want is:
- Return data of this ActiveDataProvider along with some other data. Like all data from ActiveDataProvider in one object and other data say some flag values in another object.
For example:
[
"some_other_data":{
-----
},
"dataProvider": {
"device_id": "552255445511",
"dated": "2016-03-15 23:00:04",
"speed": "73.30",
"power": null,
"ignition": null,
"ac": null,
"address": "52",
"latitude": "30.4575",
"longitude": "76.1",
"devices": {
"vehicle_number": "UK 6S Z 5555",
"vehicle_type": "0"
}
}
]
The issue is when I return it as:
return array('some_other_data'=>$somedata, 'dataProvider'=>$dataProvider);
then the result is like:
{
"some_other_data": 0,
"dataProvider": {
"query": {
"sql": null,
"on": null,
"joinWith": null,
"select": null,
"selectOption": null,
"distinct": null,
"from": null,
"groupBy": null,
"join": null,
"having": null,
"union": null,
"params": [],
"where": {
"tk103_current_location.device_id": {
"sql": null,
"on": null,
"joinWith": null,
"select": [
"device_id"
],
"selectOption": null,
"distinct": null,
"from": null,
"groupBy": null,
"join": null,
"having": null,
"union": null,
"params": [],
"where": {
"transporter_id": 22
},
"limit": null,
"offset": null,
"orderBy": null,
"indexBy": null,
"modelClass": "api\\modules\\v1\\models\\Tk103Devices",
"with": null,
"asArray": null,
"multiple": null,
"primaryModel": null,
"link": null,
"via": null,
"inverseOf": null
}
},
"limit": null,
"offset": null,
"orderBy": null,
"indexBy": null,
"modelClass": "api\\modules\\v1\\models\\Tk103CurrentLocation",
"with": null,
"asArray": null,
"multiple": null,
"primaryModel": null,
"link": null,
"via": null,
"inverseOf": null
},
"key": null,
"db": null,
"id": null
}
}
i.e. ActiveDataProvider is returning the schema like data in the result, not the actual result.
Please give me a clue or hint how to force this dataProvider to return actual data, not the architecture by which it is trying to return data.