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


PHP Book::with方法代码示例

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


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

示例1: borrowList

 public function borrowList()
 {
     if (Datatable::shouldHandle()) {
         return Datatable::collection(Book::with('author')->orderBy('id', 'desc')->get())->showColumns('id', 'title', 'amount', 'stock')->addColumn('author', function ($model) {
             return $model->author->name;
         })->addColumn('borrow', function ($model) {
             $html = '<a href="' . route('books.borrow', $model->id) . '" class="btn btnn"> <i class="mdi-action-grade"></i> </a>';
             return $html;
         })->searchColumns('title', 'amount', 'author')->orderColumns('title', 'amount', 'author')->make();
     }
 }
开发者ID:ryanda,项目名称:larapus,代码行数:11,代码来源:MemberController.php

示例2: download

 public function download($id)
 {
     $book = Book::with(array('chapter' => function ($query) {
         $query->orderBy('order', 'asc');
     }, 'chapter.element' => function ($query) {
         $query->orderBy('order', 'asc');
     }))->where("id", "=", $id)->get();
     $view = View::make('pdf/result', array("book" => $book));
     $pdf = new TCPDF();
     $pdf->AddPage();
     $pdf->writeHTML($view, true, false, true, false, '');
     $filename = public_path() . '/pdf/test.pdf';
     $pdf->output($filename, 'F');
     return Response::download($filename);
 }
开发者ID:spark942,项目名称:supinternet-projects,代码行数:15,代码来源:PdfController.php

示例3: search

 public static function search($query)
 {
     # If there is a query, search the library with that query
     if ($query) {
         # Eager load tags and author
         $books = Book::with('tags', 'author')->whereHas('author', function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhereHas('tags', function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhere('title', 'LIKE', "%{$query}%")->orWhere('published', 'LIKE', "%{$query}%")->get();
     } else {
         # Eager load tags and author
         $books = Book::with('tags', 'author')->get();
     }
     return $books;
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:16,代码来源:Book.php

示例4: index

 public function index()
 {
     if (Datatable::shouldHandle()) {
         return Datatable::collection(Book::with('author')->orderBy('id', 'desc')->get())->showColumns('id', 'title', 'amount')->addColumn('author', function ($model) {
             return $model->author->name;
         })->addColumn('1', function ($model) {
             $html = '<a href="' . route('admin.books.edit', $model->id) . '" class="btn btnn"> <i class="mdi-editor-mode-edit"></i> </a>';
             return $html;
         })->addColumn('2', function ($model) {
             $html = Form::open(['route' => ['admin.books.destroy', $model->id], 'method' => 'delete']);
             $html .= '<button class="btn btnn" type="submit"> <i class="mdi-action-delete"></i> </button>';
             $html .= Form::close();
             return $html;
         })->searchColumns('title', 'amount', 'author')->orderColumns('title', 'amount', 'author')->make();
     }
     return View::make('books.index')->withTitle('Buku');
 }
开发者ID:ryanda,项目名称:larapus,代码行数:17,代码来源:BooksController.php

示例5: search

 /**
  * Search among books, authors and tags
  * @return Collection
  */
 public static function search($query)
 {
     # If there is a query, search the library with that query
     if ($query) {
         # Eager load tags and author
         $books = Book::with('tags', 'author')->whereHas('author', function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhereHas('tags', function ($q) use($query) {
             $q->where('name', 'LIKE', "%{$query}%");
         })->orWhere('title', 'LIKE', "%{$query}%")->orWhere('published', 'LIKE', "%{$query}%")->get();
         # Note on what `use` means above:
         # Closures may inherit variables from the parent scope.
         # Any such variables must be passed to the `use` language construct.
     } else {
         # Eager load tags and author
         $books = Book::with('tags', 'author')->get();
     }
     return $books;
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:23,代码来源:Book.php

示例6: getBooks

 public function getBooks()
 {
     $booklist1 = Book::with('Chapter')->with('Publisher')->get();
     return $booklist1;
 }
开发者ID:nverdhan,项目名称:qdbwrite,代码行数:5,代码来源:Book.php

示例7: getEdit

 public function getEdit($id)
 {
     $book = Book::with('author')->findOrFail($id);
     $authors = Author::getIdNamePair();
     return View::make('book_edit')->with('book', $book)->with('authors', $authors);
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:6,代码来源:BookController.php

示例8: postEdit

 /**
  * Process the "Edit a book form"
  * @return Redirect
  */
 public function postEdit()
 {
     try {
         $book = Book::with('tags')->findOrFail(Input::get('id'));
     } catch (exception $e) {
         return Redirect::to('/book')->with('flash_message', 'Book not found');
     }
     try {
         # http://laravel.com/docs/4.2/eloquent#mass-assignment
         $book->fill(Input::except('tags'));
         $book->save();
         # Update tags associated with this book
         if (!isset($_POST['tags'])) {
             $_POST['tags'] = array();
         }
         $book->updateTags($_POST['tags']);
         return Redirect::action('BookController@getIndex')->with('flash_message', 'Your changes have been saved.');
     } catch (exception $e) {
         return Redirect::to('/book')->with('flash_message', 'Error saving changes.');
     }
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:25,代码来源:BookController.php

示例9: getIndex

 public function getIndex()
 {
     $books = Book::with('Author')->get();
     return View::make('book_list')->with('books', $books);
 }
开发者ID:ngeshlew,项目名称:laravel-e-commerce-book-store,代码行数:5,代码来源:BookController.php

示例10: create_book_without_isbn

 public function create_book_without_isbn()
 {
     $this->assertEquals(new Book('Example', new Author('Test')), Book::with()->name('Example')->author(new Author('Test'))->create());
 }
开发者ID:xp-forge,项目名称:partial,代码行数:4,代码来源:UsageTest.class.php


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