Reputation: 301
i want to get column name only if its possible
//item table , column new_values data
{"item_name":"
Chopstick",
"item_quantity":"4",
"item_brand":"d",
"item_serialno":"3",
"item_tag":"New",
"item_categories":"Assets",
"item_unitcost":"4",
"item_depriciation":"5",
"item_location":
"Not Deployed",
"user_assign":"None",
"department":"Not Assigned","id":36}
//controller
$audits=audits::select('new_values')->get();
//Blade
@foreach($audits as $colName => $value)
{{ $colName }}
@endforeach
Upvotes: 0
Views: 61
Reputation: 8618
As I understand you are using Audit model package If yes then you can use this
@foreach($audits as $audit)
@foreach($audit->new_values as $colName => $value)
{{ $colName }}
// use @dd($aud->new_values, $colName) for see what is value
// other logic
@endforeach
@endforeach
Upvotes: 1
Reputation: 3527
$json = json_decode($aud->new_values);
foreach ($json as $name => $value) {
// Here you have your $name
}
Upvotes: 1