As you mentioned in the comments, the value of $data->attachment is actually a string. In order to iterate over it in a loop you will need to convert it back to an array.
So if you change your loop to:
@foreach(json_decode($data->attachment) as $attachment)
{{ $attachment->filename }}
@endforeach
you should get what you want.
I would add that the correct place for this conversion should really be in your controller, not your view.
Your question was not entirely clear so this is all assuming you knew what you were doing when you used a foreach loop, meaning you actually have multiple entries in the $data->attachment array. If it is just the one attachment and you are really just trying to get the filename, then you don't need a loop, all you need is to say:
{{ json_decode($data->attachment)->filename }}
and again I would add that really that all belongs in your controller so that in your view you would end up with something like {{ $filename }}
$attachment = $data->attachment->toArray()and pass this$attachmentvariable to view and iterateforeachloop.[{"filename":"hello.jpg", "location":"/home/my_folder"}]foreachneeds array or object to iterate but you have JSON data. So try as below may it help: <?php $attachment = $data->attachment()->toArray(); ?> in your view