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


PHP Book::find方法代码示例

本文整理汇总了PHP中Book::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::find方法的具体用法?PHP Book::find怎么用?PHP Book::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


在下文中一共展示了Book::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update a book
  *
  * @param $book_id
  * @return Response
  */
 public function update($book_id)
 {
     $input = Input::only('isbn13', 'title', 'author', 'price');
     $book = Book::find($book_id);
     $book->update($input);
     return Response::json(['data' => $book]);
 }
开发者ID:nguyen-tien-mulodo,项目名称:packback-rest-api-101,代码行数:13,代码来源:BookController.php

示例2: queryWithoutConstraints

 public function queryWithoutConstraints()
 {
     $books = Book::find(1);
     //$books = Book::first();
     //$books = Book::all();
     Book::pretty_debug($books);
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:7,代码来源:DemoController.php

示例3: testCanGetResultsAsArrayOfModels

 public function testCanGetResultsAsArrayOfModels()
 {
     self::insertFixture();
     $books = Book::find()->all();
     $this->assertEquals("My life", $books[0]->title);
     $this->assertEquals("My life, II", $books[1]->title);
 }
开发者ID:julien-c,项目名称:mongovel,代码行数:7,代码来源:ModelTest.php

示例4: sandbox

 public static function sandbox()
 {
     // Testaa koodiasi täällä
     //View::make('helloworld.html');
     $torakat = Book::find(1);
     $books = Book::all();
     Kint::dump($books);
     Kint::dump($torakat);
 }
开发者ID:samiahl,项目名称:Tsoha-Bootstrap,代码行数:9,代码来源:hello_world_controller.php

示例5: edit

 public function edit($bid)
 {
     $_action = 'edit';
     $_viewtype = 'book/manage';
     $_viewdata = array('env' => $this->_env, 'action' => $_action, 'book_id' => $bid);
     $book = Book::find($bid);
     $_viewdata['book'] = $book;
     return View::make($_viewtype, $_viewdata);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:9,代码来源:BookController.php

示例6: testFind

 function testFind()
 {
     $title = "Anathem";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Snow Crash";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $result = Book::find($test_book->getId());
     $this->assertEquals($result, $test_book);
 }
开发者ID:umamiMike,项目名称:library-1,代码行数:11,代码来源:BookTest.php

示例7: test_find

 function test_find()
 {
     $title = "Three Blind Mice";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Chicken Dog";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $result = Book::find($test_book->getId());
     $this->assertEquals($test_book, $result);
 }
开发者ID:juliocesardiaz,项目名称:Library,代码行数:11,代码来源:BookTest.php

示例8: testHasOne

 /** */
 public function testHasOne()
 {
     $books = Book::find();
     foreach ($books as $book) {
         $this->assertIsA($book->author, 'Author');
         $this->assertIsA($book, 'Book');
     }
     $this->assertEqual($book->author->name, 'Andrei Cristescu');
     // TBD. This is not supported right now!
     // $book->author->delete();
     // $this->assertEqual(sizeof(Book::find()), 0);
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:13,代码来源:HasOneTest.php

示例9: 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

示例10: saveBook

 public function saveBook()
 {
     $book = Input::get('book');
     $chapters = Input::get('chapters');
     $bookMdl = Book::find($book['id']);
     $bookMdl->name = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $book['name']);
     $bookMdl->urlname = str_replace(' ', '-', iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $book['name']));
     $bookMdl->save();
     foreach ($chapters as $key => $chapter) {
         if ($chapter['id']) {
             $chapMdl = Chapter::find($chapter['id']);
         } else {
             $chapMdl = new Chapter();
         }
         if ($chapter['id'] && $chapter['isDeleted']) {
             $chapMdl->delete();
         } else {
             $chapMdl->book_id = $chapter['book_id'];
             $chapMdl->title = $chapter['title'];
             $chapMdl->markerdata = count($chapter['markerdata']) ? json_encode($chapter['markerdata']) : null;
             $chapMdl->order = $chapter['order'];
             $chapMdl->save();
             if (count($chapter['elements'])) {
                 foreach ($chapter['elements'] as $key => $element) {
                     if ($element['id']) {
                         $elementMdl = Element::find($element['id']);
                     } else {
                         $elementMdl = new Element();
                     }
                     if ($element['id'] && $element['isDeleted']) {
                         $elementMdl->delete();
                     } else {
                         $elementMdl->chapter_id = $chapMdl->id ?: $element['chapter_id'];
                         $elementMdl->order = $element['order'];
                         $elementMdl->type = $element['type'];
                         if ($element['type'] == 4 || $element['type'] == 5) {
                             $elementMdl->content = json_encode($element['content']);
                         } else {
                             $elementMdl->content = $element['content'];
                         }
                         $elementMdl->note = $element['note'];
                         $elementMdl->save();
                     }
                 }
             }
         }
     }
     echo json_encode(['ok']);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:49,代码来源:ElementController.php

示例11: test_find

 function test_find()
 {
     //Arrange
     $title = "The Cat in the Hat";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Misery";
     $test_book2 = new Book($title2);
     $test_book2->save();
     //Act
     $id = $test_book->getId();
     $result = Book::find($id);
     //Assert
     $this->assertEquals($test_book, $result);
 }
开发者ID:jtorrespdx,项目名称:library,代码行数:15,代码来源:BookTest.php

示例12: testFind

 function testFind()
 {
     //Arrange
     $id = null;
     $name = "A Series of Unfortunate Events";
     $test_book = new Book($id, $name);
     $test_book->save();
     $name2 = "Fresh Off the Boat";
     $test_book2 = new Book($id, $name2);
     $test_book2->save();
     //Act
     $result = Book::find($test_book->getId());
     //Assert
     $this->assertEquals($test_book, $result);
 }
开发者ID:kellimargaret,项目名称:2015.08.26.Library,代码行数:15,代码来源:BookTest.php

示例13: getPrev

 public function getPrev($chid)
 {
     $_action = 'show';
     $chapter = Chapter::find($chid);
     $book = Book::find($chapter->book_id);
     $firstTextElement = Element::where('chapter_id', '=', $chid)->where('type', '!=', '2')->first();
     $firstImage = Element::where('chapter_id', '=', $chid)->where('type', '=', '2')->first();
     $tmpELement = ['id' => $firstTextElement['id'], 'chapter_id' => $firstTextElement['chapter_id'], 'order' => $firstTextElement['order'], 'type' => $firstTextElement['type'], 'content' => $firstTextElement['content'], 'note' => $firstTextElement['note']];
     if ($firstTextElement['type'] == 4 || $firstTextElement['type'] == 5) {
         $tmpELement['content'] = json_decode($firstTextElement['content'], true);
         //dd($element['content']);
     }
     $prevInfo = ['chapter' => $chapter, 'book' => $book, 'info' => $tmpELement ?: null, 'img' => $firstImage ?: null];
     echo json_encode($prevInfo, JSON_NUMERIC_CHECK);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:15,代码来源:ChapterController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = Request::all();
     $rules = ['isbn1' => 'required|numeric', 'isbn2' => 'numeric', 'title' => 'required|alpha', 'publication' => 'required|alpha', 'author' => 'required|numeric', 'subject' => 'required|numeric', 'onstock' => 'required|numeric', 'orderquantity' => 'required|numeric', 'orderlevel' => 'required|numeric', 'price' => 'required|numeric', 'year' => 'required|numeric'];
     $message = ['isbn1' => 'ISBN 1 should not be empty.', 'isbn1' => 'ISBN 1 may contain numbers only.', 'isbn2' => 'ISBN 2 may contain numbers only.', 'title' => 'Title should not be empty.', 'title' => 'Title may contain letters only.', 'publicaiton' => 'Publication should not be empty.', 'publicaiton' => 'Publication may contain letters only.', 'author' => 'Author should not be empty.', 'author' => 'Author may contain numbers only.', 'subject' => 'Subject should not be empty.', 'subject' => 'Subect may contain numbers only.', 'onstock' => 'On Stock should not be empty.', 'onstock' => 'On Stock may contain numbers only.', 'orderquantity' => 'Order Quantity should not be empty.', 'orderquantity' => 'Order Quantity may contain numbers only.', 'orderlevel' => 'Order Level should not be empty.', 'orderlevel' => 'Order Level may contain numbers only.', 'price' => 'Price should not be empty.', 'price' => 'Price may contain numbers only.', 'year' => 'Year should not be empty.', 'year' => 'Year may not contain numbers only.'];
     $validation = Validator::make($data, $rules, $message);
     if ($validation->passes()) {
         if (Book::find($data['authorcode'])) {
             return back()->withInput();
         } else {
         }
     } else {
         return Redirect::back()->withInput()->withErrors($validation);
     }
 }
开发者ID:jMelgar101,项目名称:Classnotch,代码行数:20,代码来源:BookController.php

示例15: testFind

 function testFind()
 {
     //Arrange
     $book_name = "Intro to Art";
     $test_book = new Book($book_name);
     $test_book->save();
     $book_name2 = "Intro to Spanish";
     $test_book2 = new Book($book_name2);
     $test_book2->save();
     //Act
     $search_id = $test_book->getId();
     $result = Book::find($search_id);
     //Assert
     $this->assertEquals($test_book, $result);
 }
开发者ID:kevintokheim,项目名称:Library,代码行数:15,代码来源:BookTest.php


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