• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP app\Book类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: foreach

 function getExample7()
 {
     /*$book = new Book();
       $results = $book->where('published', '>', 1950)->get();
       foreach($results as $result)
       {
           echo $result->title.'<br/>';
       }
       echo 'Number found is '.count($results).'<br/>';
       return 'example7';*/
     $author = new \App\Author();
     $author->first_name = 'J.K';
     $author->last_name = 'Rowling';
     $author->bio_url = 'https://en.wikipedia.org/wiki/J._K._Rowling';
     $author->birth_year = '1965';
     $author->save();
     dump($author->toArray());
     $book = new \App\Book();
     $book->title = "Harry Potter and the Philosopher's Stone";
     $book->published = 1997;
     $book->cover = 'http://prodimage.images-bn.com/pimages/9781582348254_p0_v1_s118x184.jpg';
     $book->purchase_link = 'http://www.barnesandnoble.com/w/harrius-potter-et-philosophi-lapis-j-k-rowling/1102662272?ean=9781582348254';
     $book->author()->associate($author);
     # <--- Associate the author with this book
     $book->save();
     dump($book->toArray());
     return 'Example 7';
 }
开发者ID:vthilHarvard,项目名称:foobooks,代码行数:28,代码来源:PracticeController.php


示例2: includeComments

 /**
  * Include comments.
  *
  * @param  \App\Book $book
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeComments(Book $book, $params)
 {
     if ($params) {
         $this->validateParams($params);
     }
     list($limit, $offset) = $params->get('limit') ?: config('api.include.limit');
     list($orderCol, $orderBy) = $params->get('order') ?: config('api.include.order');
     $comments = $book->comments()->limit($limit)->offset($offset)->orderBy($orderCol, $orderBy)->get();
     return $this->collection($comments, new \App\Transformers\CommentTransformer());
 }
开发者ID:appkr,项目名称:rest,代码行数:18,代码来源:BookTransformer.php


示例3: testProcessBookShow

 /**
  *
  * Tests the module showing details of a single book is working by first adding a new book
  * and matching the data inserted vs data seen.
  *
  */
 public function testProcessBookShow()
 {
     //create a book
     $book = new Book();
     $book->title = 'The Hobbit';
     $book->author = 'Tolkien';
     $book->save();
     //see if the created book shows the same details used earlier
     $bookShowURL = '/books/' . $book->id;
     $this->visit($bookShowURL)->see('Tolkien')->see('The Hobbit');
 }
开发者ID:alihammadraza,项目名称:books,代码行数:17,代码来源:BookControllerTest.php


示例4: store

 public function store(Request $request)
 {
     $this->validate($request, ['bk_isbn' => 'required|max:225', 'bk_title' => 'required|max:225', 'bk_author' => 'required|max:225', 'bk_publisher' => 'required|max:225', 'bk_count' => 'required|integer']);
     $books = new Book();
     $books->bk_isbn = $request->bk_isbn;
     $books->bk_title = $request->bk_title;
     $books->bk_author = $request->bk_author;
     $books->bk_publisher = $request->bk_publisher;
     $books->bk_count = $request->bk_count;
     $books->bk_desc = $request->bk_desc;
     $books->save();
     return redirect('books');
 }
开发者ID:priatmoko,项目名称:crud-larave,代码行数:13,代码来源:BookController.php


示例5: run

 public function run()
 {
     DB::table('books')->truncate();
     for ($i = 0; $i < 10; $i++) {
         $book = new Book();
         $book->book_name = str_random(10);
         $book->book_auther = str_random(10);
         $book->book_press = str_random(10);
         $book->book_num = 10;
         $book->book_res = 10;
         $book->save();
     }
 }
开发者ID:fooklook,项目名称:books,代码行数:13,代码来源:BooksTableSeeder.php


示例6: schoolClicked

 public function schoolClicked($id)
 {
     $schools = School::all();
     $programs = Program::where('school_id', '=', $id)->get();
     $books = Book::where('school_id', '=', $id)->get();
     return view('home')->with('programs', $programs)->with('schools', $schools);
 }
开发者ID:ZhipengZeng,项目名称:txbooks.ca,代码行数:7,代码来源:SidebarController.php


示例7: update

 public function update($id)
 {
     $user_id = \Request::input('user_id');
     $checkBorrowCount = BookUser::whereUser_idAndStatus($user_id, 'pinjam')->count();
     $checkOrderCount = BookUser::whereUser_idAndStatus($user_id, 'pesan')->count();
     $checkCount = $checkBorrowCount + $checkOrderCount;
     if ($checkCount < 5) {
         $check = BookUser::whereUser_idAndBook_idAndStatus($user_id, $id, 'pinjam')->count();
         if ($check < 1) {
             $book = Book::find($id);
             $book->stock -= 1;
             $book->save();
             $data = new BookUser();
             $data->user_id = $user_id;
             $data->book_id = $id;
             $data->status = 'pinjam';
             $data->save();
             return redirect('operator/transactions')->with('successMessage', 'Berhasil meminjam buku.');
         } else {
             return redirect('operator/borrow')->with('errorMessage', 'User hanya bisa meminjam 1 buku dengan judul yang sama.');
         }
     } else {
         return redirect('operator/borrow')->with('errorMessage', 'User Hanya bisa memesan/meminjam 5 buku');
     }
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:25,代码来源:BorrowController.php


示例8: getList

 /**
  * @return \Illuminate\View\View
  */
 public function getList()
 {
     $currentUser = \Auth::user();
     $userBooks = $currentUser->books;
     $freeBooks = Book::whereNull('user_id')->paginate(10);
     return view('books', ['userBooks' => $userBooks, 'freeBooks' => $freeBooks]);
 }
开发者ID:VasylKozyrenko,项目名称:library,代码行数:10,代码来源:BookController.php


示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = [['asin' => '4844339451', 'name' => 'Laravel リファレンス[Ver.5.1 LTS 対応] Web職人好みの新世代PHPフレームワーク'], ['asin' => 'B00WHEJDKK', 'name' => 'Laravelエキスパート養成読本 [モダンな開発を実現するPHPフレームワーク!]'], ['asin' => 'B00F418SQ8', 'name' => 'Vagrant入門ガイド']];
     foreach ($books as $book) {
         Book::updateOrCreate($book);
     }
 }
开发者ID:shin1x1,项目名称:phpkansai-20151216-demo,代码行数:12,代码来源:BookSeeder.php


示例10: order

 /**
  * Proses order buku dari member.
  *
  * @return Response
  */
 public function order($id)
 {
     if (Auth::user()->name) {
         $stock = Book::find($id)->stock;
         if ($stock > 0) {
             $user_id = Auth::user()->id;
             $checkBorrowCount = BookUser::whereUser_idAndStatus($user_id, 'pinjam')->count();
             $checkOrderCount = BookUser::whereUser_idAndStatus($user_id, 'pesan')->count();
             $checkCount = $checkBorrowCount + $checkOrderCount;
             if ($checkCount < 5) {
                 $checkBorrow = BookUser::whereUser_idAndBook_idAndStatus($user_id, $id, 'pinjam')->count();
                 $checkOrder = BookUser::whereUser_idAndBook_idAndStatus($user_id, $id, 'pesan')->count();
                 if ($checkBorrow < 1 && $checkOrder < 1) {
                     $book = Book::find($id);
                     $book->stock -= 1;
                     $book->save();
                     $data = new BookUser();
                     $data->user_id = $user_id;
                     $data->book_id = $id;
                     $data->status = 'pesan';
                     $data->save();
                     return redirect('/')->with('message', 'Berhasil memesan buku ' . $book->title);
                 } else {
                     return redirect('/')->withErrors('Hanya bisa memesan/meminjam 1 buku dengan judul yang sama.');
                 }
             } else {
                 return redirect('/')->withErrors('Hanya bisa memesan/meminjam 5 buku');
             }
         } else {
             return redirect('/')->withErrors('Stok buku kosong');
         }
     } else {
         return redirect('/')->with('requiredName', $id);
     }
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:40,代码来源:OrderController.php


示例11: run

 public function run()
 {
     DB::table('books')->delete();
     Book::create(['title' => 'A Tale of Two Cities', 'author' => 'Charles Dickens', 'year' => '1859']);
     Book::create(['title' => 'The Lord of the Rings', 'author' => 'J. R. R. Tolkien', 'year' => '1954']);
     Book::create(['title' => 'And Then There Were None', 'author' => 'Agatha Christie', 'year' => '1939']);
     Book::create(['title' => 'The Hobbit', 'author' => 'J. R. R. Tolkien', 'year' => '1937']);
     Book::create(['title' => 'She: A History of Adventure', 'author' => 'H. Rider Haggard', 'year' => '1887']);
     Book::create(['title' => 'The Lion the Witch and the Wardrobe', 'author' => 'C. S. Lewis', 'year' => '1950']);
     Book::create(['title' => 'The Da Vinci Code', 'author' => 'Dan Brown', 'year' => '2003']);
     Book::create(['title' => 'The Catcher in the Rye', 'author' => 'J. D. Salinger', 'year' => '1951']);
     Book::create(['title' => 'Lolita', 'author' => 'Vladimir Nabokov', 'year' => '1955']);
     Book::create(['title' => 'Anne of Green Gables', 'author' => 'Lucy Maud Montgomery', 'year' => '1908']);
     Book::create(['title' => 'The Name of the Rose', 'author' => 'Umberto Eco', 'year' => '1980']);
     Book::create(['title' => 'The Eagle Has Landed', 'author' => 'Jack Higgins', 'year' => '1975']);
     Book::create(['title' => 'Watership Down', 'author' => 'Richard Adams', 'year' => '1972	']);
     Book::create(['title' => 'The Ginger Man', 'author' => 'J. P. Donleavy', 'year' => '1955']);
     Book::create(['title' => 'The Bridges of Madison County', 'author' => 'Robert James Waller', 'year' => '1991']);
     Book::create(['title' => 'The Tale of Peter Rabbit', 'author' => 'Beatrix Potter', 'year' => '1902']);
     Book::create(['title' => 'Harry Potter and the Deathly Hallows', 'author' => 'J. K. Rowling', 'year' => '2007']);
     Book::create(['title' => 'Jonathan Livingston Seagull', 'author' => 'Richard Bach', 'year' => '1970']);
     Book::create(['title' => 'A Message to Garcia', 'author' => 'Elbert Hubbard', 'year' => '1899']);
     Book::create(['title' => 'Flowers in the Attic', 'author' => 'V. C. Andrews', 'year' => '1979']);
     Book::create(['title' => 'War and Peace', 'author' => 'Leo Tolstoy', 'year' => '1869']);
     Book::create(['title' => 'The Adventures of Pinocchio', 'author' => 'Carlo Collodi', 'year' => '1881']);
     Book::create(['title' => 'Kane and Abel', 'author' => 'Jeffrey Archer', 'year' => '1979']);
     Book::create(['title' => 'To Kill a Mockingbird', 'author' => 'Harper Lee', 'year' => '1960']);
     Book::create(['title' => 'Valley of the Dolls', 'author' => 'Jacqueline Susann', 'year' => '1966']);
     Book::create(['title' => 'Gone with the Wind', 'author' => 'Margaret Mitchell', 'year' => '1936']);
     Book::create(['title' => 'The Diary of a Young Girl', 'author' => 'Anne Frank', 'year' => '1947']);
     Book::create(['title' => 'One Hundred Years of Solitude', 'author' => 'Gabriel Garcia Marquez', 'year' => '1967']);
     Book::create(['title' => 'The Thorn Birds', 'author' => 'Colleen McCullough', 'year' => '1977']);
     Book::create(['title' => 'The Revolt of Mamie Stover', 'author' => 'William Bradford Huie', 'year' => '1951']);
     Book::create(['title' => 'The Girl with the Dragon Tattoo', 'author' => 'Stieg Larsson', 'year' => '2005']);
 }
开发者ID:Qualenal,项目名称:BooksWebsite,代码行数:35,代码来源:DatabaseSeeder.php


示例12: borrow2

 public function borrow2()
 {
     //$user = user::where('email', '=', Input::get('bemail'))->firstOrFail();
     $returnData = "";
     $name = Input::get("name");
     $email = Input::get("email");
     if (Request::ajax()) {
         $userCount = User::where('email', '=', Input::get('email'))->count();
         $bookCount = Book::where('barcode', '=', Input::get('barcode'))->count();
         if ($userCount == 1) {
             $returnData = $returnData . " user existed ";
             $user = User::where('email', '=', Input::get('email'))->find(1);
         }
         if ($userCount == 0) {
             $name = Input::get("name");
             $email = Input::get("email");
             $user = user::create(array('email' => $email, 'name' => $name));
             $returnData = $returnData . " user is created ";
         }
         if ($bookCount == 1) {
             $returnData = $returnData . " book existed ";
             $book = Book::where('barcode', '=', Input::get('barcode'))->find(1);
         }
         if ($bookCount == 0) {
             $title = Input::get('title');
             $author = Input::get('author');
             $barcode = Input::get('barcode');
             $book = book::create(array('title' => $title, 'author' => $author, 'barcode' => $barcode));
             $returnData = $returnData . " book is created ";
         }
         $borrow = Borrow::create(array('user_id' => $user->id, 'book_id' => $book->id));
         $returnData = $returnData . " borrowing is successful user id =" . $user->id . " book id =" . $book->id;
     }
     return $returnData;
 }
开发者ID:klokand,项目名称:Nintex,代码行数:35,代码来源:HomeController.php


示例13: addCart

 public function addCart(Request $request)
 {
     $book = Book::find($request->id);
     if ($request->quantity <= $book->quantity) {
         $cart_old = Cart::where('book_id', '=', $request->id)->where(function ($query) use($request) {
             $query->where('user_id', '=', Auth::check() ? Auth::user()->id : 0)->orWhere('remember_token', '=', $request->header('X-CSRF-TOKEN'));
         });
         if ($cart_old->count() > 0) {
             $check = $cart_old->firstOrFail()->update(['quantity' => $cart_old->firstOrFail()->quantity + $request->quantity]);
         } else {
             $cart = new Cart();
             $cart->user_id = Auth::check() ? Auth::user()->id : null;
             $cart->book_id = $request->id;
             $cart->quantity = $request->quantity;
             $cart->remember_token = $request->header('X-CSRF-TOKEN');
             $check = $cart->save();
         }
         if ($check) {
             return "true";
         } else {
             return "Lỗi thêm hàng vào giỏ. Vui lòng thử lại!";
         }
     } else {
         return "Quá số hàng trong kho. Vui lòng thử lại!";
     }
 }
开发者ID:phucanhhoang,项目名称:IT4895,代码行数:26,代码来源:CartController.php


示例14: editBook

 public static function editBook($data, $id)
 {
     $book = Book::find($id);
     if ($data['title'] != '') {
         $book->title = $data['title'];
     }
     if ($data['isbn10'] != '') {
         $book->isbn10 = $data['isbn10'];
     }
     $author = new Author();
     $genre = new Genre();
     $author->name = $data['author'];
     $genre->name = $data['genre'];
     $authorToRemove = Author::find($data['authors']);
     $genreToRemove = Genre::find($data['genres']);
     $exisitngAuthor = Author::find($data['existing-author']);
     $exisitngGenre = Genre::find($data['existing-genre']);
     $book->authors()->detach($authorToRemove['author_id']);
     $book->genres()->detach($genreToRemove['genre_id']);
     $book->authors()->attach($exisitngAuthor['author_id']);
     $book->genres()->attach($exisitngGenre['genre_id']);
     if ($data['author'] != '') {
         $book->authors()->save($author);
         var_dump($data['author']);
     }
     if ($data['genre'] != '') {
         $book->genres()->save($genre);
     }
     $book->save();
 }
开发者ID:traqnzlatanov77,项目名称:Lib,代码行数:30,代码来源:Book.php


示例15: index

 public function index()
 {
     //$book = new \App\Book();
     //$books = $book->all();
     $books = \App\Book::all();
     return view('books', ['books' => $books]);
 }
开发者ID:renasti,项目名称:oficina-laravel,代码行数:7,代码来源:BookController.php


示例16: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('books')->delete();
     Book::create(['title' => 'Eugenii Onegin', 'isbn' => '09374726342', 'price' => '10.40', 'cover' => 'onegin.jpg', 'author_id' => '1']);
     Book::create(['title' => 'Stihi', 'isbn' => '5555555555', 'price' => '8.25', 'cover' => 'esenin_stihi.jpg', 'author_id' => '2']);
     Book::create(['title' => 'Angels and demons', 'isbn' => '1111111111', 'price' => '15.99', 'cover' => 'brown_angels.jpg', 'author_id' => '3']);
 }
开发者ID:aleximillers,项目名称:estore-laravel-angular,代码行数:12,代码来源:BooksTableSeeder.php


示例17: index

 public function index()
 {
     $books = Book::with('Author')->where(function ($query) {
         $min_price = \Request::has('min_price') ? \Request::get('min_price') : null;
         $max_price = \Request::has('max_price') ? \Request::get('max_price') : null;
         $authors = \Request::has('authors') ? \Request::get('authors') : [];
         if (isset($min_price)) {
             $query->where('price', '>=', $min_price);
         }
         if (isset($max_price)) {
             $query->where('price', '<=', $max_price);
         }
         if (isset($authors)) {
             $query->where(function ($q) {
                 $input_authors = \Request::has('authors') ? \Request::get('authors') : [];
                 // $books_all = \App\Book::with('Author')->get();
                 //перебираем все чекнутые боксы
                 foreach ($input_authors as $input_author) {
                     // автор == выборка из авторов где Ид = чекнутому боксу. Первый
                     $author = \App\Author::with('books')->where('id', '=', $input_author)->first();
                     // выборка внутри выбранного автора по книгам
                     foreach ($author->books as $author_book) {
                         //запрос Айди книги == айди книг у этого автора
                         $q->orWhere('id', '=', $author_book->id);
                     }
                 }
             });
         }
     })->paginate(2);
     $authors_list = \App\Author::all();
     return view('books.list', compact('books', 'authors_list'));
 }
开发者ID:aleximillers,项目名称:estore-laravel-angular,代码行数:32,代码来源:BooksController.php


示例18: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $bookUpdate = Request::all();
     $book = Book::find($id);
     $book->update($bookUpdate);
     return redirect('books');
 }
开发者ID:shaneguna,项目名称:bookstore,代码行数:13,代码来源:BookController.php


示例19: store

 /**
  * Store a newly created resource in storage.
  *
  * @param CreateCartRequest|Request $request
  * @return Response
  */
 public function store(CreateCartRequest $request)
 {
     $book = Book::find($request->bookId);
     $Quantity = $request->Quantity;
     Cart::add(['id' => $book->id, 'name' => $book->book_title, 'qty' => $Quantity, 'price' => $book->price, 'options' => array('size' => 'large')]);
     $cart = $this->getCartsContent();
     return view('cart.index', compact('cart'));
 }
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:14,代码来源:CartController.php


示例20: updateBook

 public function updateBook(Request $request, $id)
 {
     $Book = Book::find($id);
     $Book->title = $request->input('title');
     $Book->author = $request->input('author');
     $Book->save();
     return response()->json($Book);
 }
开发者ID:aranajhonny,项目名称:Api-libros,代码行数:8,代码来源:BookController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP app\Branch类代码示例发布时间:2022-05-23
下一篇:
PHP app\Board类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap