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


PHP Book::all方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $books = Book::all();
     $transactions = User::order()->get();
     return view('operator.order.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]);
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:12,代码来源:OrderController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $books = Book::all();
     $transactions = User::join('book_users', 'users.id', '=', 'book_users.user_id')->join('books', 'books.id', '=', 'book_users.book_id')->select('books.title', 'users.name', 'book_users.created_at', 'book_users.updated_at', 'book_users.status')->whereNotIn('status', ['pesan'])->get();
     return view('operator.borrow.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]);
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:12,代码来源:BorrowController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $books = Book::all();
     return view('books.index', compact('books'));
     //return view('welcome');
 }
开发者ID:umayanga123,项目名称:laravel_simple_app_test,代码行数:12,代码来源:BookController.php

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

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $books = Book::all();
     $transactions = User::transactionBorrow()->orderBy('created_at', 'desc')->get();
     return view('operator.transactions.index', ['user' => $user, 'books' => $books, 'transactions' => $transactions]);
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:12,代码来源:TransactionController.php

示例6: getBookWithEloquent

 function getBookWithEloquent()
 {
     $books = new Book();
     foreach ($books->all() as $book) {
         echo $book->title . '<br/>';
     }
     return 'getBookWithEloquent';
 }
开发者ID:vthilHarvard,项目名称:foobooks,代码行数:8,代码来源:PracticeController.php

示例7: foreach

 function getExample9()
 {
     #eager load the authors with the books
     $books = \App\Book::all();
     foreach ($books as $book) {
         echo $book->author->first_name . ' ' . $book->author->last_name . ' wrote ';
     }
     dump($books->toArray());
 }
开发者ID:joshvisk,项目名称:foobooks,代码行数:9,代码来源:PracticeController.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Add to 10 random user 5 random books
     $users = User::all('id')->random(5);
     foreach ($users as $user) {
         $books = Book::all('id')->random(3);
         foreach ($books as $book) {
             DB::table('users_books')->insert(['user_id' => $user->id, 'book_id' => $book->id]);
         }
     }
 }
开发者ID:a1ex7,项目名称:front-end,代码行数:16,代码来源:UsersBooksTableSeeder.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $books = Book::all();
     foreach ($books as $book) {
         //TODO: make a method in model for retreiving authors and genres
         $authors = Book::find($book->book_id)->authors()->get();
         $genres = Book::find($book->book_id)->genres()->get();
         $book->authors = $authors;
         $book->genres = $genres;
     }
     return view('books/books', ['books' => $books]);
 }
开发者ID:traqnzlatanov77,项目名称:Lib,代码行数:17,代码来源:BooksController.php

示例10: index

 public function index()
 {
     $books = \App\Book::all();
     $category = \App\Category::all();
     // return \App\Book::with(["Author"])->get();
     // dd($books->toArray());
     // if (!\Auth::user()->admin == '1')
     // {
     //     return \Redirect::to('index')->with('error', 'You are not Admin');
     // }
     return view('admin.bookslist', compact('books', 'category'));
 }
开发者ID:aleximillers,项目名称:estore-laravel-angular,代码行数:12,代码来源:AdminController.php

示例11: index

 /**
  * Displays a listing of all the books available and allows their sorting as well.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $sortBy = Input::get('sortBy');
     $order = Input::get('order');
     if ($sortBy and $order == 'asc') {
         $books = Book::orderBy($sortBy, 'ASC')->get();
     } elseif ($sortBy and $order == "desc") {
         $books = Book::orderBy($sortBy, 'DESC')->get();
     } else {
         $books = Book::all();
     }
     return view('home')->with('books', $books);
 }
开发者ID:alihammadraza,项目名称:books,代码行数:18,代码来源:BookController.php

示例12: showBooks

 public function showBooks()
 {
     $books = Book::all();
     function getExcerpt($str, $startPos = 0, $maxLength = 100)
     {
         if (strlen($str) > $maxLength) {
             $excerpt = substr($str, $startPos, $maxLength - 3);
             $lastSpace = strrpos($excerpt, ' ');
             $excerpt = substr($excerpt, 0, $lastSpace);
             $excerpt .= ' ...';
         } else {
             $excerpt = $str;
         }
         return $excerpt;
     }
     foreach ($books as $book) {
         $book->description = getExcerpt($book->description, 0, 1000);
     }
     return View('books', compact('books'));
 }
开发者ID:AmirMehrabi,项目名称:sabzName,代码行数:20,代码来源:PagesController.php

示例13: importBooks

 public function importBooks()
 {
     $rules = array('csvfile' => 'required|mimes:csv,txt');
     try {
         $file = Input::file('csvfile');
         if (is_null($file)) {
             throw new Exception("File upload required");
         }
         Excel::load($file, function ($reader) {
             $results = $reader->all();
             foreach ($results as $row) {
                 $book = new Book();
                 # First row should be like "Title, Author"
                 $data = array('title' => $row->title, 'author' => $row->author);
                 $book->fill($data);
                 $book->save();
             }
         });
     } catch (Exception $e) {
         return Redirect::to('/')->with(['books' => Book::all(), 'errors' => $e->getMessage()]);
     }
     return Redirect::to('/')->with(['books' => Book::all()]);
     //return Redirect::to('/')->with('csvdata', $results);
 }
开发者ID:vertexclique,项目名称:bstore,代码行数:24,代码来源:BookController.php

示例14: getNearestUser

 public function getNearestUser(Request $request, $book_id)
 {
     session_start();
     if (session_id() == "" || !isset($_SESSION['latitude'])) {
         return redirect()->route('home');
     } else {
         if (isset($_SESSION['latitude'])) {
             // get all the books from the book database.
             $books = Book::where("book_id", $book_id)->get();
             $valid_users = [];
             foreach ($books as $book) {
                 $matches = [];
                 $found_user = $book->user;
                 $theta = doubleval($found_user['longitude']) - doubleval($_SESSION['longitude']);
                 $dist = sin(deg2rad(doubleval($found_user['latitude']))) * sin(deg2rad(doubleval($_SESSION['latitude']))) + cos(deg2rad(doubleval($found_user['latitude']))) * cos(deg2rad(doubleval($_SESSION['latitude']))) * cos(deg2rad($theta));
                 $dist = acos($dist);
                 $dist = rad2deg($dist);
                 $miles = round($dist * 60 * 1.1515 * 1.609344, 1);
                 $matches['location_name'] = $found_user['location_name'];
                 $matches['firstname'] = $found_user['name'];
                 $matches['distance'] = $miles;
                 $valid_users[] = $matches;
             }
             // more suggestions based on your location
             $suggestions = [];
             $more_books = Book::all()->take(100);
             foreach ($more_books as $more) {
                 $matches = [];
                 $found_user = $more->user;
                 $theta = doubleval($found_user['longitude']) - doubleval($_SESSION['longitude']);
                 $dist = sin(deg2rad(doubleval($found_user['latitude']))) * sin(deg2rad(doubleval($_SESSION['latitude']))) + cos(deg2rad(doubleval($found_user['latitude']))) * cos(deg2rad(doubleval($_SESSION['latitude']))) * cos(deg2rad($theta));
                 $dist = acos($dist);
                 $dist = rad2deg($dist);
                 $miles = round($dist * 60 * 1.1515 * 1.609344, 1);
                 $matches['location_name'] = $found_user['location_name'];
                 $matches['firstname'] = $found_user['name'];
                 $matches['distance'] = $miles;
                 $matches['title'] = $more->title;
                 $matches['image'] = $more->image;
                 $matches['rating'] = $more->rating;
                 $matches['publisher'] = $more->publisher;
                 $matches['isbn'] = $more->isbn;
                 $suggestions[] = $matches;
             }
             // sort the array based on distance
             uasort($valid_users, function ($a) {
                 return $a['distance'];
             });
             $valid_users = array_slice($valid_users, 0, 3);
             // sort the array based on distance
             // uasort($suggestions, function ($b) {
             //     return $b['distance'];
             // });
             $suggestions = $this->sort_by_key($suggestions, 'distance');
             $suggestions = array_slice($suggestions, 0, 18);
             $book = $books[0];
             // return $suggestions;
             return view("static.foundBooks", compact("valid_users", "book", "suggestions"));
         }
     }
 }
开发者ID:PrakharSrivastav,项目名称:bookbarterclub,代码行数:61,代码来源:PagesController.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $books = Book::all();
     return view('index')->withBooks($books);
 }
开发者ID:H3xept,项目名称:uni-ingegneria,代码行数:10,代码来源:BookshelfController.php


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