本文整理匯總了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');
}
}