i have table contian 3 column, id + slug + name... And name column is a json column and data stored like that
Id: 1
Slug: test
Name: {en:test;ar:تجربه}
now in balde i just want to show name.en only not {en:test;ar:تجربه}
اهلا.
You have to decode the JSON string.
Example: {{ json_decode($data->name)['en'] }}
Though it is better to have a getter on your Model, e.g:
Model.php:
public function getJsonNameAttribute()
{
return json_decode($data->name);
}
In your view:
{{ $data->json_name['en'] }}
Use @Manvir Singh's answer. It is better.
Uaing json_decode is not a good idea, in Model file you can cast your column like this
public $casts = [ 'json_column' => 'object' ]
Now your json column will be treated as object and you can access
$data->json_column->en