当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::where方法代码示例

本文整理汇总了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');
 }
开发者ID:Bine0511,项目名称:RDF-Demo,代码行数:7,代码来源:HomeController2.php

示例2: update

 function update()
 {
     $params = $this->input->post();
     $obj = new Book();
     $obj->where('id', $params['id'])->update($params);
     echo $obj->check_last_query();
 }
开发者ID:pojok-webdev,项目名称:pattimura,代码行数:7,代码来源:books.php

示例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;
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:14,代码来源:Book.php

示例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();
 }
开发者ID:johnarben2468,项目名称:samplecrud,代码行数:13,代码来源:BookController.php

示例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'));
     }
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:13,代码来源:SearchController.php

示例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);
 }
开发者ID:shayan-ys,项目名称:online_shop,代码行数:20,代码来源:ProductController.php

示例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);
     }
 }
开发者ID:balliuera,项目名称:Book_io,代码行数:44,代码来源:ApiController.php

示例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);
 }
开发者ID:danielheyman,项目名称:TechDimeProjects,代码行数:19,代码来源:RelationsTest.php

示例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));
 }
开发者ID:Belar,项目名称:librific,代码行数:10,代码来源:ChapterController.php

示例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);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:12,代码来源:TravelerController.php

示例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...!');
     }
 }
开发者ID:tylerrehm07,项目名称:csci-e15,代码行数:10,代码来源:BookController.php

示例12: queryWithOrder

 public function queryWithOrder()
 {
     $books = Book::where('published', '>', 1950)->orderBy('title', 'desc')->get();
     Book::pretty_debug($books);
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:5,代码来源:DemoController.php

示例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.');
 }
开发者ID:Belar,项目名称:librific,代码行数:21,代码来源:BookController.php

示例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'));
开发者ID:johnarben2468,项目名称:samplecrud,代码行数:18,代码来源:routes.php

示例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'));
     }
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:13,代码来源:BookController.php


注:本文中的Book::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。