【发布时间】:2018-07-18 11:52:37
【问题描述】:
我的浏览页面:
@if(empty($data))
<p>No response have been attached to this entities.</p>
@else
<p>By default, it will respond with the predefined phrases. Use the form below to customize responses.</p>
@endif
控制器:
public function queries($companyID, $entityType, $entityValue)
{
$data = [];
$details = DiraQuestion::where('company_id', $companyID)->where('eType', $entityType)->where('eVal', $entityValue)->get();
foreach ($details AS $datum)
{
if (!isset($data[$datum->intent])) $data[$datum->intent] = ['question' => [], 'answer' => []];
$data[$datum->intent]['question'][$datum->queries] = $datum->id;
}
$detailsAns = DiraResponses::where('company_id', $companyID)->where('eType', $entityType)->where('eVal', $entityValue)->get();
foreach ($detailsAns AS $datum)
{
if (!isset($data[$datum->intent])) $data[$datum->intent] = ['question' => [], 'answer' => []];
$data[$datum->intent]['answer'][$datum->reply] = $datum->id;
}
ksort($data);
return view('AltHr.Chatbot.queries', compact('data','entityType','entityValue','companyID'));
}
我制作了上面显示的控制器和视图,但是当没有数据时我似乎无法弄清楚问题是什么,它仍然显示如下:
我试图让它显示数据,但是当没有数据时,它会显示其他内容。
当我 dd(); 时,我有两个有数据和没有数据的例子;
首先是数据:
第二个没有数据:
所以没有数据的应该显示错误消息之类的其他内容。
【问题讨论】:
标签: php html mysql database laravel