laravel框架关于搜索功能的实现

前端之家收集整理的这篇文章主要介绍了laravel框架关于搜索功能的实现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

这里的搜索功能主要基于表单get提交实现的

分类: @endforeach 文章标题: 文章标题">查询">

PHP部分逻辑

on('article.class_id','=','category.id'); })->select(['article.id','category.class_name','article.status','article.title_editing','article.update_time'])->where('article.class_id',$_GET['class'])->orderBy('release_time','desc')->paginate($shownum); }elseif($_GET['keywords']){ $postdata = Article::leftJoin('category','article.update_time'])->where('article.title_editing',$_GET['keywords'])->orderBy('release_time','desc')->paginate($shownum);

}else{
$postdata = Article::leftJoin('category','article.update_time'])->orderBy('release_time','desc')->paginate($shownum);
}
}else{
//echo '2222';
$postdata = Article::leftJoin('category',function($join) {
$join->on('article.class_id','category.id');
})->select(['article.id','desc')->paginate($shownum);
}
//分类id不是父id
$category = DB::table('category')->where('parent_id','!=','0')->get();
//渲染页面 传递 参数
return view('backend.article_list',['postdata'=>$postdata,'shownum'=>$shownum,'category'=>$category]);
}

原文链接:https://www.f2er.com/laravel/16253.html

猜你在找的Laravel相关文章