Laravel: How do I parse this json data in view blade?

后端 未结 8 1381
耶瑟儿~
耶瑟儿~ 2020-11-29 03:11

Currently this is my view

{{ $leads }}

And this is the output

{\"error\":false,\"member\":[{\"id\":\"1\",\"firstName\":\"fi         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 03:47

    If your data is coming from a model you can do:

    App\Http\Controller\SomeController

    public function index(MyModel $model)
    {
        return view('index', [
            'data' => $model->all()->toJson(),
        ]);
    }
    

    index.blade.php

    @push('footer-scripts')
      
    @endpush
    

提交回复
热议问题