在 octobercms 中获取延迟保存的图像
Getting deffered saved images in octobercms
您好,我在 octobercms 中使用 'uploader' 和站点搜索插件。
使用上传器插件,我在保存后在我的发布模型中保存了多个图像,它们显示在后端区域但没有检索。
我正在以这种方式检索 attachMany 关系 postingimage 但是当我在 content.htm 文件中打印 {{result.model}} 它显示像这样的空数组
{"title":"gdsag","brandname":"Yamaha","description":"gdsga","price":5887,"name":"Rawalpindi","postingimage":[]}
无法获取模型中的延迟保存图像
在网站搜索插件中获取这样的图片
if ($item->postingimage) {
return [
'title' => $item->title,
'text' => $item->description,
'text' => $item->price,
'text' => $item->brandname,
'text' => $item->name,
'thumb' => $item->postingimage->first(),
'relevance' => $relevance, // higher relevance results in a higher
'model' => $item,
];
我在组件中的初始化方法
public function init()
{
$component = $this->addComponent(
'Responsiv\Uploader\Components\FileUploader',
'fileUploader',
['deferredBinding' => true]
);
$component->bindModel('postingimage', new Posting);
}
我在提交表单后以这种方式保存图像
$posting->save(null, post('_session_key'));
有什么帮助吗?
我得到了这个问题的解决方案
$matching = Posting::join('fsz_posting_tblbrands') // ... do your join
// Now refetch the needed models with all needed relations
$items = Posting::with('postingimage')->whereIn('id', $matching->pluck('id'))->get();
还要确保您的 $item 实际上是模型的一个实例,而不仅仅是一个集合。如果它是一个简单的集合,我们将无法加载关系
您好,我在 octobercms 中使用 'uploader' 和站点搜索插件。 使用上传器插件,我在保存后在我的发布模型中保存了多个图像,它们显示在后端区域但没有检索。 我正在以这种方式检索 attachMany 关系 postingimage 但是当我在 content.htm 文件中打印 {{result.model}} 它显示像这样的空数组
{"title":"gdsag","brandname":"Yamaha","description":"gdsga","price":5887,"name":"Rawalpindi","postingimage":[]}
无法获取模型中的延迟保存图像 在网站搜索插件中获取这样的图片
if ($item->postingimage) {
return [
'title' => $item->title,
'text' => $item->description,
'text' => $item->price,
'text' => $item->brandname,
'text' => $item->name,
'thumb' => $item->postingimage->first(),
'relevance' => $relevance, // higher relevance results in a higher
'model' => $item,
];
我在组件中的初始化方法
public function init()
{
$component = $this->addComponent(
'Responsiv\Uploader\Components\FileUploader',
'fileUploader',
['deferredBinding' => true]
);
$component->bindModel('postingimage', new Posting);
}
我在提交表单后以这种方式保存图像
$posting->save(null, post('_session_key'));
有什么帮助吗?
我得到了这个问题的解决方案
$matching = Posting::join('fsz_posting_tblbrands') // ... do your join
// Now refetch the needed models with all needed relations
$items = Posting::with('postingimage')->whereIn('id', $matching->pluck('id'))->get();
还要确保您的 $item 实际上是模型的一个实例,而不仅仅是一个集合。如果它是一个简单的集合,我们将无法加载关系