求助 laravel + tntsearch
1. 运行环境
1). 当前使用的 Laravel 版本? 8.83.27
2). 当前使用的 php/php-fpm 版本? PHP 版本:7.4.33
2. 问题描述?
有用过 laravel + tntsearch 的朋友吗?这篇帖子中,
// 这里是啥意思?
'content' => $this->content->body,
模型支持联表搜索吗?文章 title 一个表,文章内容另一个表
可以 只要修改下 toSearchableArray 方法就行
// app/Article.php
public function toSearchableArray()
{
return [
'id' => $this->id,
'title' => $this->title,
'content' => $this->content->body,
];
}
content 和 body 是 文章标题和文章内容的字段吗?
模型关联《Laravel 10 中文文档》
content 是模型关联的表,body 是该关联表里的字段。