Avoid json_encode() and Use @json() Blade Directive in Laravel
But do you know Laravel has an awesome blade directive for
json_encode. You can use @json for the same task that you do with json_encode. Instead of manually calling
json_encode, you may use the
@json Blade directive. The
@json directive accepts the same arguments as of PHP's
Hope it can help you.