I am fairly new to laravel so I would like to know how do you grab a the data from 'data' with laravel query
the dynamo database is like this
{
"subdomain": "subdomain",
"uuid": "uuid_1234",
"data": {
"credit_limit": 1200,
"id": 1234,
"name": "Allan",
"number": 651234568
}
}
and i want to only get from the database
"credit_limit": 1200,
"id": 1234,
"name": "Allan",
"number": 651234568
the code I used is
$dynamo = DB::connection('dynamo')
->table('module_details')
->whereIndex('subdomain-index')
->where('uuid', '=', strtolower($this->Class).'_'.array_get($result['data'], 'id'))
->wherePartitionKey('subdomain', '=', Config::get('node.subdomain'))
->select('data')
->get();
but this code gave me the result of
"data": {
"credit_limit": 1200,
"id": 1234,
"name": "Allan",
"number": 651234568
}
CodePudding user response:
try this
$dynamo = DB::connection('dynamo')
->table('module_details')
->whereIndex('subdomain-index')
->where('uuid', '=', strtolower($this->Class).'_'.array_get($result['data'], 'id'))
->wherePartitionKey('subdomain', '=', Config::get('node.subdomain'))
->select('data.credit_limit','data.id','data.name','data.number')
->get();
it will give you specific data that you want