📜  laravel 创建搜索 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:35.685000             🧑  作者: Mango

代码示例1
public function index(){
      // // we need to show all data from "blog" table
      // $blogs = Blog::all();
      // // show data to our view
      // return view('blog.index',['blogs' => $blogs]);

      $search = Request::get('search');
      $blogs = Blog::where('title','like','%'.$search.'%')->orderBy('id')->paginate(6);
      return view('blog.index',['blogs' => $blogs]);
    }