Blogger Information
Blog 142
fans 5
comment 0
visits 130501
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php部分逻辑
php开发大牛
Original
788 people have browsed it

public function article_list(){
 //echo 'zoule';exit; 测试表单是否走进方法中 大家随意写
 $shownum = 1;
 if(array_key_exists('class',$_GET)||array_key_exists('keywords',$_GET)){
  //echo '111';
  if($_GET['class']){
  //Article模型 leftJoin表连接 查询根据俩个表里的这些字段来执行
    $postdata = Article::leftJoin('category', function($join) {
     $join->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', function($join) {
     $join->on('article.class_id', '=', 'category.id');
    })->select(['article.id','category.class_name','article.status','article.title_editing','article.update_time'])->where('article.title_editing','=',$_GET['keywords'])->orderBy('release_time','desc')->paginate($shownum);
   
  }else{
    $postdata = Article::leftJoin('category', function($join) {
     $join->on('article.class_id', '=', 'category.id');
    })->select(['article.id','category.class_name','article.status','article.title_editing','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','category.class_name','article.status','article.title_editing','article.update_time'])->orderBy('release_time','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]);
}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post