• <i id='BYLop'><tr id='BYLop'><dt id='BYLop'><q id='BYLop'><span id='BYLop'><b id='BYLop'><form id='BYLop'><ins id='BYLop'></ins><ul id='BYLop'></ul><sub id='BYLop'></sub></form><legend id='BYLop'></legend><bdo id='BYLop'><pre id='BYLop'><center id='BYLop'></center></pre></bdo></b><th id='BYLop'></th></span></q></dt></tr></i><div id='BYLop'><tfoot id='BYLop'></tfoot><dl id='BYLop'><fieldset id='BYLop'></fieldset></dl></div>
    <legend id='BYLop'><style id='BYLop'><dir id='BYLop'><q id='BYLop'></q></dir></style></legend>

    <small id='BYLop'></small><noframes id='BYLop'>

          <bdo id='BYLop'></bdo><ul id='BYLop'></ul>

      1. <tfoot id='BYLop'></tfoot>
      2. 无法 json_encode() 数组或 Laravel 集合:“不支持类型

        时间:2023-09-22
      3. <tfoot id='hwcDE'></tfoot>

      4. <small id='hwcDE'></small><noframes id='hwcDE'>

            <i id='hwcDE'><tr id='hwcDE'><dt id='hwcDE'><q id='hwcDE'><span id='hwcDE'><b id='hwcDE'><form id='hwcDE'><ins id='hwcDE'></ins><ul id='hwcDE'></ul><sub id='hwcDE'></sub></form><legend id='hwcDE'></legend><bdo id='hwcDE'><pre id='hwcDE'><center id='hwcDE'></center></pre></bdo></b><th id='hwcDE'></th></span></q></dt></tr></i><div id='hwcDE'><tfoot id='hwcDE'></tfoot><dl id='hwcDE'><fieldset id='hwcDE'></fieldset></dl></div>
                <tbody id='hwcDE'></tbody>
              1. <legend id='hwcDE'><style id='hwcDE'><dir id='hwcDE'><q id='hwcDE'></q></dir></style></legend>

                • <bdo id='hwcDE'></bdo><ul id='hwcDE'></ul>
                  本文介绍了无法 json_encode() 数组或 Laravel 集合:“不支持类型"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我不知道我做错了什么,因为它适用于应用程序中的所有其他模型.我多次刷新并重新播种数据库.这些模型扩展了相同的抽象方法.

                  I don't know what I'm doing wrong since it works with all the other models in the app. I refreshed and reseeded the database multiple times. The models extend the same abstract methods.

                  这是控制器中的代码:

                  $substrates = $this->substrates->all()->toArray();
                  $temp = json_encode($substrates);
                  dd($temp, json_last_error(), json_last_error_msg(), $substrates);
                  

                  这是 dd() 输出:

                  This is the dd() output:

                  false
                  8
                  "Type is not supported"
                  
                  array:119 [▼
                  
                    0 => array:21 [▼
                  
                      "id" => 1
                      "name" => "Wood Free"
                      "machine_id" => 2
                      "classification" => "Cover"
                      "origins" => "Coming Soon"
                      "duplex" => true
                      "color" => "Translucents"
                      "texture" => "Leather"
                      "finish" => "Felt"
                      "product_type" => "Sheet"
                      "caliper" => "0.06"
                      "m_weight" => 70
                      "width" => "46.40"
                      "height" => "32.00"
                      "pic" => stream resource @17 ▶}
                      "price" => "0.30"
                      "created_by" => 38
                      "updated_by" => 16
                      "deleted_at" => null
                      "created_at" => "2018-01-27 08:00:11"
                      "updated_at" => "2018-01-27 08:00:11"
                    ]
                  
                    1 => array:21 [▶] ....
                  

                  当我使用 JSON_PARTIAL_OUTPUT_ON_ERROR 时,我得到一个 json 字符串.

                  When I use JSON_PARTIAL_OUTPUT_ON_ERROR I get a json string.

                  推荐答案

                  错误的原因是你在 pic 中存储了一个 stream 资源无法序列化为 JSON 的序列化对象的字段.

                  The reason for the error is the fact, that you're storing a stream resource in pic field of the serialised object that can't be serialised to JSON.

                  您可以通过在模型中设置 $hidden 属性来告诉 Eloquent 模型在将所选属性转换为数组时跳过它们:

                  You can tell Eloquent model to skip selected attributes when they're converted to an array by setting a $hidden attribute in your model:

                  class Substrate extends Model {
                    protected $hidden = ['pic'];
                  }
                  

                  这篇关于无法 json_encode() 数组或 Laravel 集合:“不支持类型"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Laravel Eloquent - 查询数据透视表 下一篇:Laravel whereIn whereJsonContains 的实现

                  相关文章

                  最新文章

                • <i id='d0T1B'><tr id='d0T1B'><dt id='d0T1B'><q id='d0T1B'><span id='d0T1B'><b id='d0T1B'><form id='d0T1B'><ins id='d0T1B'></ins><ul id='d0T1B'></ul><sub id='d0T1B'></sub></form><legend id='d0T1B'></legend><bdo id='d0T1B'><pre id='d0T1B'><center id='d0T1B'></center></pre></bdo></b><th id='d0T1B'></th></span></q></dt></tr></i><div id='d0T1B'><tfoot id='d0T1B'></tfoot><dl id='d0T1B'><fieldset id='d0T1B'></fieldset></dl></div>

                      <bdo id='d0T1B'></bdo><ul id='d0T1B'></ul>
                    <tfoot id='d0T1B'></tfoot>

                    <small id='d0T1B'></small><noframes id='d0T1B'>

                  1. <legend id='d0T1B'><style id='d0T1B'><dir id='d0T1B'><q id='d0T1B'></q></dir></style></legend>