本文整理汇总了PHP中app\Book::whereRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::whereRaw方法的具体用法?PHP Book::whereRaw怎么用?PHP Book::whereRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Book
的用法示例。
在下文中一共展示了Book::whereRaw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$books = Book::whereRaw('taken < curdate() - interval 30 day')->get();
foreach ($books as $book) {
$url = route('books');
$user = User::find($book->user_id);
$this->dispatch(new MailSender($user, $book, 'Did you forget to return a book to library?', 'emails.reminder', $url));
}
}
示例2: index
public function index()
{
//
$kwords = Input::get('kword', '');
$whereStr = "book_name like '%" . $kwords . "%'";
$cou = \App\Book::whereRaw($whereStr)->count();
$faqs = \App\Book::whereRaw($whereStr)->get();
$myResult = array('cou' => $cou, 'faqs' => $faqs);
// echo $myResult;
if ($cou == 0) {
session()->flash('message_info', '没有查询到结果!');
}
return view('faq', ['faqs' => $myResult['faqs'], 'cou' => $myResult['cou'], 'kword' => '$kwords']);
}
示例3: getfind
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function getfind()
{
if (Input::has('q')) {
$title = Input::get('q');
$total = Book::whereRaw('title like "%' . $title . '%" or author like "%' . $title . '%"')->count();
$listItem = Book::whereRaw('title like "%' . $title . '%" or author like "%' . $title . '%"')->paginate(ITEM_PER_PAGE);
// $total = Book::whereRaw('title like "%'.$title.'%"')->count();
// $listItem = Book::whereRaw('title like "%'.$title.'%"')->paginate(4);
return view('book.find', compact('listItem', 'total'));
} else {
redirect()->route('home');
}
}