小编Mun*_*ber的帖子

不支持json_encode()和Array或laravel集合,“不支持类型”

我不知道我在做什么错,因为它可以与应用程序中的所有其他模型一起使用。我刷新并重新播种了数据库多次。并且这些模型扩展了相同的抽象方法

这是控制器中的代码:

    $substrates = $this->substrates->all()->toArray();
    $temp = json_encode($substrates);
    dd($temp, json_last_error(), json_last_error_msg(), $substrates);
Run Code Online (Sandbox Code Playgroud)

这是dd()的输出:false 8“不支持类型”

数组: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" …
Run Code Online (Sandbox Code Playgroud)

php json laravel eloquent laravel-5

2
推荐指数
1
解决办法
795
查看次数

标签 统计

eloquent ×1

json ×1

laravel ×1

laravel-5 ×1

php ×1