laravel模型查询的时候报 Array to string conversion
记录下遇到的问题, 使用模型查询的时候, 就报了下面的错

代码如下
<?php namespace App\Http\Controllers\WeChat; use App\Http\Controllers\Controller; use App\Models\Post; class PostController extends Controller { public function getAllPosts() { dd(Post::all()); } }昨晚找了半天都没有发现问题,
最后经过高人指点, 是模型里面的问题, 原本的代码是:<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Post extends Model { protected $table = ['wechat_posts']; }是因为
$table的问题, 哭晕在厕所了
, 应该是下面的写法:protected $table = 'wechat_posts';
本作品采用《CC 协议》,转载必须注明作者和本文链接
关于 LearnKu
推荐文章: