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


PHP Book::where方法代码示例

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


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

示例1: getIndex

 /**
  * Responds to requests to GET /books
  */
 public function getIndex(Request $request)
 {
     // Get all the books "owned" by the current logged in users
     // Sort in descending order by id
     $books = \App\Book::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
     return view('books.index')->with('books', $books);
 }
开发者ID:jpedroza,项目名称:laravelvideobooks.aacax.net,代码行数:10,代码来源:BookController.php

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

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

示例4: book

 public function book($id)
 {
     $settings = Setting::first();
     $books = Book::get();
     $currentbook = Book::where('id', $id)->firstOrFail();
     return view('front.book', ['books' => $books, 'settings' => $settings, 'currentbook' => $currentbook]);
 }
开发者ID:ElliottLandsborough,项目名称:lararel-simple-library,代码行数:7,代码来源:FrontController.php

示例5: deleteAllWithBookType

 public function deleteAllWithBookType($book_type_id)
 {
     // Get All Books
     $books = Book::where('book_type_id', $book_type_id)->delete();
     // Passing data to response service
     return $this->responseService->returnMessage($books, 'No Books were Found.');
 }
开发者ID:owemus,项目名称:personal_be,代码行数:7,代码来源:BookService.php

示例6: bookCheckedOutByUser

 /**
  * @Given 書籍 :bookName 已被 :username 借出
  */
 public function bookCheckedOutByUser($bookName, $username)
 {
     $book = Book::where('name', $bookName)->first();
     $user = User::where('username', $username)->first();
     $book->available = false;
     $book->save();
     factory(CheckoutHistory::class)->create(['book_id' => $book->id, 'user_id' => $user->id]);
 }
开发者ID:RainyRuRu,项目名称:bookshelf,代码行数:11,代码来源:BookshelfContext.php

示例7: foreach

 function getExample10()
 {
     $book = \App\Book::where('title', '=', 'The Great Gatsby')->first();
     echo $book->title . ' is tagged with : ';
     foreach ($book->tags as $tag) {
         echo $tag->name . ' ';
     }
 }
开发者ID:joshvisk,项目名称:foobooks,代码行数:8,代码来源:PracticeController.php

示例8:

 function getExample7()
 {
     $book = \App\Book::where('author', 'LIKE', '%Scott%')->first();
     if ($book) {
         return $book->title;
     } else {
         return 'Book not found.';
     }
 }
开发者ID:BrendanJohn,项目名称:foobooks,代码行数:9,代码来源:PracticeController.php

示例9: run

 /**
  * Treat this method as a controller action.
  * Return view() or other content to display.
  */
 public function run()
 {
     //
     $listItem = Book::where('cate_id', '=', $this->config['id'])->orderBy(DB::raw('RAND()'))->take($this->config['count'])->get();
     // return view("widgets.featured_books", [
     //     'config' => $this->config,
     //     'featuredItem' => $featuredItem
     // ]);
     return view("widgets.samecategory_books", compact('listItem'));
 }
开发者ID:hoangtrungweb,项目名称:cungdocsach,代码行数:14,代码来源:SamecategoryBooks.php

示例10: create

 public function create()
 {
     if (Auth::check()) {
         $user = Auth::user();
         $count = Book::where('user_id', '=', $user->id)->count();
         $mybooks = Book::where('user_id', '=', $user->id)->orderBy('updated_at', 'desc')->take(10)->get();
         return view('sell')->with('mybooks', $mybooks)->with('count', $count);
     } else {
         return redirect()->route('getLogin');
     }
 }
开发者ID:ZhipengZeng,项目名称:txbooks.ca,代码行数:11,代码来源:BookController.php

示例11: Book

 function getExample5()
 {
     //DELETE
     $book = new Book();
     $harry_potter = Book::where('author', '=', 'J.K.Rowling')->first();
     if ($harry_potter != null) {
         $harry_potter->delete();
         echo 'deleted Harry Potter';
     }
     return 'example5';
 }
开发者ID:vthilHarvard,项目名称:foobooks,代码行数:11,代码来源:PracticeController.php

示例12: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['1'], 'A Fire in the Deep' => ['5'], 'Deepness in the Sky' => ['10']];
     foreach ($books as $title => $rating) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($rating as $ratingName) {
             $rating = \App\Rating::where('rating', 'LIKE', $ratingName)->first();
             $book->ratings()->save($rating);
         }
     }
 }
开发者ID:snoyface,项目名称:Scifi-book-reviewer,代码行数:16,代码来源:BookRatingTableSeeder.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['The Great Gatsby' => ['novel', 'fiction', 'classic', 'wealth'], 'The Bell Jar' => ['novel', 'fiction', 'classic', 'women'], 'I Know Why the Caged Bird Sings' => ['autobiography', 'nonfiction', 'classic', 'women']];
     foreach ($books as $title => $tags) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
开发者ID:vthilHarvard,项目名称:foobooks-1,代码行数:16,代码来源:BookTagTableSeeder.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $books = ['1.mp4' => ['mysql', 'security', 'php', 'model'], '2.mp4' => ['mysql', 'security', 'php', 'controller'], '3.mp4' => ['ui', 'nonfiction', 'js', 'view'], '4.mp4' => ['mysql', 'ui', 'html', 'css']];
     foreach ($books as $title => $tags) {
         $book = \App\Book::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \App\Tag::where('name', 'LIKE', $tagName)->first();
             $book->tags()->save($tag);
         }
     }
 }
开发者ID:jpedroza,项目名称:foobooks-master-test.aacax.net,代码行数:16,代码来源:BookTagTableSeeder.php

示例15: search

 public function search(Request $request)
 {
     if (strlen($request->search) >= 1) {
         $books = Book::where('book_title', 'like', "%{$request->search}%")->paginate(3);
         if ($books->total() > 1) {
             Flash::success('Result');
         } else {
             Flash::success('Not Found');
         }
     } else {
         $books = Book::where('book_title', 'like', "%aaaaaaaaaaaaaaaaaaaa%")->paginate(3);
     }
     return view('home', compact('books'));
 }
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:14,代码来源:HomeController.php


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