本文整理汇总了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;
}
示例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();
}
示例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]);
}
示例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'));
}
示例5: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return response(['books' => Book::all()], 200);
}
示例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();