0
我有以下问题?当您在我们的平台上搜索foo时,您会得到一个空白页面的搜索结果。如果用户在不在我们平台上的搜索查询中输入搜索结果,并显示一个像“很抱歉但我们的平台上没有foo”这样的小反应,我想要输入一个搜索结果。Laravel搜索结果
在我们searchcontroller.php下控制器我有以下
<?php
class SearchController extends BaseController
{
public function getIndex()
{
$search = Request::get('q');
if (empty($search)) {
return Redirect::to('gallery');
}
$extends = explode(' ', $search);
$images = Images::where('title', 'LIKE', '%' . $search . '%')
->orWhere('tags', 'LIKE', '%' . $search . '%')->orWhere('category', '=', $search)
->where('deleted_at', '=', NULL)->where('approved','=',DB::raw(1))->orderBy('created_at', 'desc');
foreach ($extends as $extend) {
$images->orWhere('tags', 'LIKE', '%' . $extend . '%')
->orWhere('title', 'LIKE', '%' . $search . '%')
->orWhere('image_description', 'LIKE', '%' . $search . '%');
}
$images = $images->paginate(30);
return View::make('gallery/index')
->with('images', $images)
->with('title', t('Searching for').' "' . ucfirst($search) . '"');
}
}
“我想...”然后做。具体是什么问题? – bjb568