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


PHP Book::all方法代码示例

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


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

示例1: all

 /**
  * Get all books
  * if no limit specified, a default number 50 is filtered
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function all()
 {
     $limit = input('limit', 50);
     $books = Book::all()->take($limit);
     event(new ExampleEvent());
     return $books;
 }
开发者ID:aphiwadChhoeun,项目名称:Book-API,代码行数:13,代码来源:BookController.php

示例2: bookItemWithTransformer

 public function bookItemWithTransformer()
 {
     $fractal = new Manager();
     $book = Book::all()->random(1);
     //$book = Book::find(1);
     $resource = new Item($book, new BookTransformer());
     return $fractal->createData($resource)->toJson();
 }
开发者ID:kongtoonarmy,项目名称:laravel-transformers,代码行数:8,代码来源:BookController.php

示例3: index

 public function index()
 {
     if ($this->petugas == null) {
         header("Location: " . base . "/Auth");
         exit;
     }
     $books = Book::all();
     $this->view->render('admin/book', ['books' => $books, 'petugas' => $this->petugas]);
 }
开发者ID:blegoh,项目名称:Web,代码行数:9,代码来源:BookController.php

示例4: index

 public function index()
 {
     if (auth()->user()->can('book_manage_all')) {
         $books = Book::all();
     } else {
         $books = Book::whereUserId(auth()->user()->id)->get();
     }
     return view('admin.books.index', compact('books'));
 }
开发者ID:phelipperibeiro,项目名称:book_store_laravel,代码行数:9,代码来源:BooksController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return response(['books' => Book::all()], 200);
 }
开发者ID:jrm2k6,项目名称:i-heart-reading,代码行数:9,代码来源:BooksController.php

示例6: function

});
$app->post('/authors', function (Request $request) use($app) {
    $this->validate($request, Author::VALIDATION_RULES);
    $new_author = new Author($request->all());
    $new_author->save();
    return redirect('authors/' . $new_author->id);
});
$app->post('/authors/{id}/update', function ($id, Request $request) {
    $this->validate($request, Author::VALIDATION_RULES);
    $author = Author::find($id);
    $author->update($request->all());
    return redirect('authors/' . $author->id);
});
// --- BOOKS ---
$app->get('/books', function () use($app) {
    $books = Book::all();
    return view('books.index', ['books' => $books]);
});
$app->get('/books/new', function (Request $request) use($app) {
    $authors = Author::all();
    return view('books.new', ['authors' => $authors, 'request' => $request]);
});
$app->post('/books', function (Request $request) use($app) {
    $this->validate($request, Book::VALIDATION_RULES);
    $new_book = new Book($request->all());
    $new_book->save();
    return redirect('books/' . $new_book->id);
});
$app->get('/books/{id}', function ($id, Request $request) use($app) {
    $book = Book::find($id);
    $authors = Author::all();
开发者ID:simonbacquie,项目名称:get-started-with-lumen,代码行数:31,代码来源:routes.php


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