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


PHP Book::all方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = User::all();
     $book_count = Book::all()->count();
     $chapter_count = Chapter::all()->count();
     return View::make('admin.admin_panel', array('pageTitle' => 'Admin Panel', 'users' => $users, 'book_count' => $book_count, 'chapter_count' => $chapter_count));
 }
开发者ID:Belar,项目名称:librific,代码行数:12,代码来源:AdminController.php

示例2: sandbox

 public static function sandbox()
 {
     // Testaa koodiasi täällä
     //View::make('helloworld.html');
     $torakat = Book::find(1);
     $books = Book::all();
     Kint::dump($books);
     Kint::dump($torakat);
 }
开发者ID:samiahl,项目名称:Tsoha-Bootstrap,代码行数:9,代码来源:hello_world_controller.php

示例3: test_delete_by_find_all

 public function test_delete_by_find_all()
 {
     $books = Book::all();
     foreach ($books as $model) {
         $model->delete();
     }
     $res = Book::all();
     $this->assert_equals(0, count($res));
 }
开发者ID:scorplev,项目名称:php-activerecord,代码行数:9,代码来源:ActiveRecordWriteTest.php

示例4: firstPageBooks

 public static function firstPageBooks()
 {
     //now this method searches all the books just like "listingBooks" -method,
     //but later on (when we have more books in the database), this method wants some
     //subset of books (like every books that start with "s", or most favourite books or books selected by admin or...)
     $books = Book::all();
     //        self::sort_books($books);
     View::make('general/firstpage.html', array('books' => $books));
 }
开发者ID:mclantta,项目名称:Tsoha-Bootstrap,代码行数:9,代码来源:BookController.php

示例5: collections

 public function collections()
 {
     $collection = Book::all();
     //echo Pre::render($collection);
     # The many faces of a Eloquent Collection object...
     # Treat it like a string:
     echo $collection;
     # Treat it like an array:
     //foreach($collection as $book) {
     //	echo $book['title']."<br>";
     //}
     # Treat it like an object:
     //foreach($collection as $book) {
     // echo $book->title."<br>";
     //}
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:16,代码来源:DemoController.php

示例6: run

 public function run()
 {
     $faker = Faker\Factory::create();
     //getting all books from the table
     $books = Book::all();
     $isbn_list = array();
     //getting all ISBNs into a single array
     foreach ($books as $book) {
         array_push($isbn_list, $book->isbn);
     }
     DB::table('library_books')->delete();
     for ($i = 0; $i < 15; $i++) {
         $fake_library_id = $faker->numberBetween(1, 10);
         $fake_book_isbn = $faker->randomElement($isbn_list);
         //checking for duplications
         if (LibraryBooks::where('user_id', '=', $fake_library_id)->where('book_isbn', '=', $fake_book_isbn)->count() > 0) {
             continue;
         }
         LibraryBooks::create(array('user_id' => $fake_library_id, 'book_isbn' => $fake_book_isbn, 'copies_no' => $faker->numerify('##')));
     }
 }
开发者ID:balliuera,项目名称:Book_io,代码行数:21,代码来源:DatabaseSeeder.php

示例7: function

<?php

// Modelo de objetos que se corresponde con la tabla de MySQL
class Book extends \Illuminate\Database\Eloquent\Model
{
    public $timestamps = false;
}
// Añadir el resto del código aquí
$app->get('/books', function () use($app) {
    // Creamos un objeto collection + json con la lista de películas
    // Obtenemos el objeto request, que representa la petición HTTP
    $req = $app->request;
    // Obtenemos la ruta absoluta de este recurso
    $absUrl = $req->getScheme() . "://" . $req->getHost() . $req->getRootUri() . $req->getResourceUri();
    // Obtenemos la lista de los libros de la base de datos y la convertimos del formato Json (el devuelto por Eloquent) a un array PHP
    $libros = json_decode(\Book::all());
    $app->view()->setData(array('url' => $absUrl, 'items' => $libros));
    // Mostramos la vista
    $app->render('booklist_template.php');
});
/*  Obtención de un libro en concreto  */
$app->get('/books/:name', function ($name) use($app) {
    // Creamos un objeto collection + json con el libro pasado como parámetro
    // Obtenemos el objeto request, que representa la petición HTTP
    $req = $app->request;
    // Obtenemos la ruta absoluta de este recurso
    $absUrl = $req->getScheme() . "://" . $req->getHost() . $req->getRootUri() . $req->getResourceUri();
    // Obtenemos el libro de la base de datos a partir de su id y la convertimos del formato Json (el devuelto por Eloquent) a un array PHP
    $p = \book::find($name);
    $libro = json_decode($p);
    $app->view()->setData(array('url' => preg_replace('/' . preg_quote('/' . $name, '/') . '$/', '', $absUrl), 'item' => $libro));
开发者ID:interfacesweb15-16,项目名称:s4_mars,代码行数:31,代码来源:books.php

示例8: testDeleteByFindAll

 public function testDeleteByFindAll()
 {
     $books = Book::all();
     foreach ($books as $model) {
         $model->delete();
     }
     $res = Book::all();
     $this->assertEquals(0, count($res));
 }
开发者ID:ruri,项目名称:php-activerecord-camelcased,代码行数:9,代码来源:ActiveRecordWriteTest.php

示例9: home

 public function home()
 {
     $rs = Book::all();
     $data = $rs->toArray();
     echo View::getView()->make('home', array('data' => $data))->render();
 }
开发者ID:muyuren,项目名称:nuf,代码行数:6,代码来源:HomeController.php

示例10: function

        echo "[]";
    }
});
$app->post('/books', function () use($app) {
    $title = $app->request->post('title');
    $author = $app->request->post('author');
    $year = $app->request->post('year');
    // Or create a new book
    $book = new Book(array('title' => $title, 'author' => $author, 'year' => $year));
    $book->save();
    echo $book->toJson();
});
$app->delete('/books/:id', function ($book_id) use($app) {
    $book = Book::find($book_id);
    $book->delete();
    $books = Book::all();
    echo $books->toJson();
});
$app->put('/books/:id', function ($book_id) use($app) {
    $title = $app->request->put('title');
    $author = $app->request->put('author');
    $year = $app->request->put('year');
    $book = Book::find($book_id);
    if ($book != null) {
        $book->id = $book_id;
        $book->title = $title;
        $book->author = $author;
        $book->year = $year;
        $book->save();
        echo $book->toJson() . $book_id . $title . $author . $year . $book->author . $book->id;
        //http://stackoverflow.com/questions/23761425/get-put-params-with-slim-php
开发者ID:TrienDo,项目名称:BestBooks,代码行数:31,代码来源:index.php

示例11: submit

 public function submit()
 {
     $books = Book::all();
     return $this->response->withCollection($books, new BookTransformer());
 }
开发者ID:erpmesh,项目名称:erphub,代码行数:5,代码来源:TriggerController.php

示例12: function

<?php

// Modelo de objetos que se corresponde con la tabla de MySQL
class Book extends \Illuminate\Database\Eloquent\Model
{
    public $timestamps = false;
}
/* Obtención de la lista de libros */
$app->get('/books', function () use($app) {
    // Creamos un objeto collection + json con la lista de libros
    // Obtenemos el objeto request, que representa la petición HTTP
    $req = $app->request;
    // Obtenemos la ruta absoluta de este recurso
    $absUrl = $req->getScheme() . "://" . $req->getHost() . $req->getRootUri() . $req->getResourceUri();
    // Obtenemos la lista de librosde la base de datos y la convertimos del formato Json (el devuelto por Eloquent) a un array PHP
    $books = json_decode(\Book::all());
    $app->view()->setData(array('url' => $absUrl, 'items' => $books));
    // Mostramos la vista
    $app->render('booklist_template.php');
});
/*  Obtención de un libro en concreto  */
$app->get('/books/:name', function ($name) use($app) {
    // Creamos un objeto collection + json con la película pasada como parámetro
    // Obtenemos el objeto request, que representa la petición HTTP
    $req = $app->request;
    // Obtenemos la ruta absoluta de este recurso
    $absUrl = $req->getScheme() . "://" . $req->getHost() . $req->getRootUri() . $req->getResourceUri();
    // Obtenemos la película de la base de datos a partir de su id y la convertimos del formato Json (el devuelto por Eloquent) a un array PHP
    $p = \Book::find($name);
    $libro = json_decode($p);
    $app->view()->setData(array('url' => preg_replace('/' . preg_quote('/' . $name, '/') . '$/', '', $absUrl), 'item' => $libro));
开发者ID:interfacesweb15-16,项目名称:s4_earth,代码行数:31,代码来源:books.php

示例13: index

 /**
  * Get all books
  *
  * @return Response
  */
 public function index()
 {
     $books = Book::all();
     return Response::json(['data' => $books]);
 }
开发者ID:nguyen-tien-mulodo,项目名称:packback-rest-api-101,代码行数:10,代码来源:BookController.php

示例14: index

function index()
{
    global $twig;
    $books = new Book();
    echo $twig->render('books_list.html', array('books' => $books->all()));
}
开发者ID:rfloriano,项目名称:rfloriano-treichel-bookstore,代码行数:6,代码来源:books.php

示例15: index

 public static function index()
 {
     $books = Book::all();
     Kint::dump($books);
     View::make('book/index.html', array('books' => $books));
 }
开发者ID:samiahl,项目名称:Tsoha-Bootstrap,代码行数:6,代码来源:book_controller.php


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