问题
如何限制 Eloquent 结果中的某一行?
设想
我只需要从结果中的一个字段中检索大约 100 个字符。目前我正在使用 join 语句,因此返回了多个结果。我基本上只需要前 100 个字符post.content
代码
public function getAll()
{
return Post::select('posts.id', 'posts.title', 'posts.content', 'posts.views', 'posts.comments', 'posts.tags', 'posts.date_created', 'users.image_url', 'users.username', 'users.toxick')
->join('users', 'posts.user_id', '=', 'users.id')
->get();
}
我不确定如何对查询进行过滤以仅返回 100 个字符。我环顾四周,但没有发现任何有用的东西,至少对我的具体情况没有。