本文整理汇总了PHP中Book::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::where方法的具体用法?PHP Book::where怎么用?PHP Book::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateNewBook
public function updateNewBook()
{
$book = Book::where('ID', '=', Input::get("id"))->get();
$book->Inhalt = Input::get("inhalt");
$book->save();
return View::make('updateNew');
}
示例2: update
function update()
{
$params = $this->input->post();
$obj = new Book();
$obj->where('id', $params['id'])->update($params);
echo $obj->check_last_query();
}
示例3: getBooksAddedInTheLast24Hours
/**
* Searches and returns any books added in the last 24 hours
*
* @return Collection
*/
public static function getBooksAddedInTheLast24Hours()
{
# Timestamp of 24 hours ago
$past_24_hours = strtotime('-1 day');
# Convert to MySQL timestamp
$past_24_hours = date('Y-m-d H:i:s', $past_24_hours);
$books = Book::where('created_at', '>', $past_24_hours)->get();
return $books;
}
示例4: delete
public function delete($id)
{
$exist = Book::where('id', $id)->count();
if ($exist == 0) {
Session::put('msgfail', 'Failed to delete book.');
return Redirect::back()->withInput();
}
$book = Book::find($id);
unlink(public_path() . "/uploads/book/" . $book->file);
Book::where('id', $id)->delete();
Session::put('msgsuccess', 'Successfully deleted book.');
return Redirect::back();
}
示例5: getSearchBooks
public function getSearchBooks($key)
{
if (isset($key)) {
$books = Book::where('name', 'like', '%' . $key . '%')->get();
if (isset($books)) {
return json_encode(array('message' => 'found', 'books' => $books->toArray()));
} else {
return json_encode(array('message' => 'empty'));
}
} else {
return json_encode(array('message' => 'invalid'));
}
}
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$product = Product::find($id)->toArray();
$additional = null;
if ($product['category'] == 'laptop') {
$additional = Laptop::where('id_product', $id)->first()->toArray();
} elseif ($product['category'] == 'book') {
$additional = Book::where('id_product', $id)->first()->toArray();
}
$product = array_merge($product, $additional);
$head = array('title' => $product['name']);
$data = array('head' => $head, 'product' => $product);
return view('product.show', $data);
}
示例7: postAdd
public function postAdd()
{
$rules = array('isbn' => 'required|size:13', 'title' => 'required|min:3', 'author' => 'required|alpha', 'category' => 'required', 'publishing_house' => 'required', 'page_no' => 'required|numeric', 'publishing_year' => 'required|max:4');
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
//all fields are set
$isbn = Input::get('isbn');
//check if isbn exists in the books table
$_test = Book::where('isbn', '=', $isbn)->first();
if ($_test != null) {
//the book is in the books table, just add him for this user
$mybook = new LibraryBooks();
$mybook->user_id = Auth::user()->id;
$mybook->book_isbn = $isbn;
$mybook->copies_no = 1;
//TODO: change this
$mybook->save();
return "This book was saved on library_books";
} else {
//the book doesn't exist in the books table
//add it there then add it to the user
$mybook = new Book();
$mybook->author = Input::get('author');
$mybook->category = Input::get('category');
$mybook->isbn = $isbn;
$mybook->page_no = Input::get('page_no');
$mybook->publishing_house = Input::get('publishing_house');
$mybook->publishing_year = Input::get('publishing_year');
$mybook->title = Input::get('title');
$mybook->save();
//now that the book was added to books
//add him to the user
$new_book = new LibraryBooks();
$new_book->user_id = Auth::user()->id;
$new_book->book_isbn = $isbn;
$new_book->copies_no = 1;
//TODO: change this
$new_book->save();
return "This was stored to books with id " . $mybook->id;
}
} else {
return Redirect::to('/api/v1/add')->withErrors($validator);
}
}
示例8: testDoubleSaveOneToMany
public function testDoubleSaveOneToMany()
{
$author = User::create(array('name' => 'George R. R. Martin'));
$book = Book::create(array('title' => 'A Game of Thrones'));
$author->books()->save($book);
$author->books()->save($book);
$author->save();
$this->assertEquals(1, $author->books()->count());
$this->assertEquals($author->_id, $book->author_id);
$author = User::where('name', 'George R. R. Martin')->first();
$book = Book::where('title', 'A Game of Thrones')->first();
$this->assertEquals(1, $author->books()->count());
$this->assertEquals($author->_id, $book->author_id);
$author->books()->save($book);
$author->books()->save($book);
$author->save();
$this->assertEquals(1, $author->books()->count());
$this->assertEquals($author->_id, $book->author_id);
}
示例9: showPrivate
public function showPrivate($sl)
{
$chapter = Chapter::where('secret_link', '=', $sl)->first();
if ($chapter->public_state == true && Book::where('id', '=', $chapter->book_id)->first()->public_state == true) {
return Redirect::to('/chapter/' . $chapter->slug);
}
$markdownParser = new MarkdownParser();
$markdownText = $markdownParser->transformMarkdown($chapter->text);
return View::make('chapter.single', array('chapter' => $chapter, 'chapter_text' => $markdownText, 'pageTitle' => 'Chapter: ' . $chapter->title));
}
示例10: myprofile
public function myprofile()
{
$_action = 'myprofile';
$_viewtype = 'traveler/self';
$_viewdata = array('env' => $this->_env, 'action' => $_action);
if (!Auth::check()) {
return Redirect::to('home/');
} else {
$_viewdata['books'] = Book::where('traveler_id', '=', Auth::user()->id)->get();
}
return View::make($_viewtype, $_viewdata);
}
示例11: getDeleteBook
public function getDeleteBook($id)
{
$book = Book::where('id', '=', $id)->first();
if ($book) {
$book->delete();
return Redirect::to('/browse-books')->with('flash_message', 'Delete successfuly!');
} else {
return Redirect::to('/browse-books')->with('flash_message', 'Delete failed! Try again...!');
}
}
示例12: queryWithOrder
public function queryWithOrder()
{
$books = Book::where('published', '>', 1950)->orderBy('title', 'desc')->get();
Book::pretty_debug($books);
}
示例13: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$book = Book::where('id', '=', $id)->orWhere('slug', '=', $id)->first();
$chapters = Chapter::where('book_id', '=', $book->id)->where('public_state', '=', true)->paginate(15);
if ($book) {
if ($book->public_state == true) {
return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title));
} elseif (Sentry::Check() && $book->author_id == Sentry::getUser()->id) {
return View::make('book.single', array('book' => $book, 'chapters' => $chapters, 'pageTitle' => 'Book: ' . $book->title));
} else {
return Redirect::to('/')->with('global_error', 'You can\'t access private resources without a secret link, which can be received from creation\'s author.');
}
}
return Redirect::to('/')->with('global_error', 'Sorry, book you are trying to reach doesn\'t exist.');
}
示例14: function
<?php
Route::get('/books', function () {
$books = DB::table('books')->paginate(10);
return View::make('management')->with('books', $books);
});
Route::get('/books/edit/{id}', function ($id) {
$exist = Book::where('id', $id)->count();
if ($exist == 0) {
Session::put('msgfail', 'Failed to edit book.');
return Redirect::back()->withInput();
}
$book = Book::find($id);
return View::make('edit_books')->with('book', $book);
});
Route::post('/books/edit/{id}', array('uses' => 'BookController@edit'));
Route::post('/books', array('uses' => 'BookController@add', 'as' => 'books'));
Route::get('/books/delete/{id}', array('uses' => 'BookController@delete'));
示例15: getBooks
public function getBooks($id)
{
if (isset($id)) {
$books = Book::where('course_id', $id)->get();
if (isset($books)) {
return json_encode(array('message' => 'found', 'books' => $books->toArray()));
} else {
return json_encode(array('message' => 'empty'));
}
} else {
return json_encode(array('message' => 'invalid'));
}
}