• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP models\Book类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: searchISBN

 public function searchISBN()
 {
     if (\Request::ajax()) {
         $data = array();
         $isbn = \Input::get('isbn');
         if (is_numeric($isbn)) {
             $book = Book::where('isbn', $isbn)->first();
             if ($book) {
                 $product = \Auth::user()->organization->products->find($book->id);
                 if ($product) {
                     // το βιβλίο υπάρχει στον οργανισμό και μπορούμε να το κάνουμε μόνο EDIT
                     $data['find'] = true;
                     $data['id'] = $book->id;
                     $data['title'] = $book->product->title;
                     $data['barcode'] = $book->product->barcode;
                     $data['notify'] = '<p>Το βιβλίο με το συγκεκριμένο ISBN <strong> υπάρχει ήδη. </strong> </p> <p>Μπορείτε να το τροποποιήσετε κάνοντας κλικ στον τίτλο:</p>';
                 } else {
                     // το βιβλίο υπάρχει σε άλλον οργανισμό και μπορούμε να το προσθέσουμε μόνο ως item
                     $data['find'] = true;
                     $data['external'] = true;
                     $data['id'] = $book->id;
                     $data['title'] = $book->product->title;
                     $data['barcode'] = $book->product->barcode;
                     $data['notify'] = '<p>Το βιβλίο με το συγκεκριμένο ISBN είναι καταχωρημένο από άλλο οργανισμό. Θέλετε να το προσθέσετε?</p>';
                 }
             }
             // else σημαίνει ότι όλα ΟΚ για create_book
         }
         return $data;
     }
     // END If
 }
开发者ID:nicsmyrn,项目名称:library,代码行数:32,代码来源:AjaxBookRepository.php


示例2: search

 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Book::find();
     $query->joinWith('author');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $dataProvider->sort->attributes['author.name'] = ['asc' => ['{{%author.name}}' => SORT_ASC], 'desc' => ['{{%author.name}}' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->author_id) {
         $query->andFilterWhere(['{{%book.author_id}}' => $this->author_id]);
     }
     if ($this->name) {
         $query->andFilterWhere(['like', '{{%book.name}}', $this->name]);
     }
     if ($this->date_from) {
         $query->andWhere('{{%book.date}} > :date_from', ['date_from' => strtotime($this->date_from)]);
     }
     if ($this->date_to) {
         $query->andWhere('{{%book.date}} < :date_to', ['date_to' => strtotime($this->date_to)]);
     }
     //        $query
     //            ->andFilterWhere(['{{%book.author_id}}' => $this->author_id])
     //            ->andFilterWhere(['like', '{{%book.name}}', $this->name])
     //            ->andWhere('{{%book.date}} > :date_from', ['date_from' => strtotime($this->date_from)])
     //            ->andWhere('{{%book.date}} < :date_to', ['date_to' => strtotime($this->date_to)]);
     return $dataProvider;
 }
开发者ID:Godscreature,项目名称:Books,代码行数:33,代码来源:BookSearch.php


示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Book::find($id)->delete();
     \Session::flash('flash_message', 'Deleted Successfully!');
     \Session::flash('flash_message_level', 'success');
     return Redirect::back();
 }
开发者ID:razikallayi,项目名称:peaceschools,代码行数:13,代码来源:LibraryController.php


示例4: actionForm

 public function actionForm($book_id)
 {
     $product = Book::findOne($book_id);
     $productImage = new BookImage();
     if (!empty($_FILES['BookImage'])) {
         $img = $_FILES['BookImage']['name']['url'];
         $ext = end(explode(".", $img));
         $name = microtime();
         $name = str_replace(' ', '', $name);
         $name = str_replace('.', '', $name);
         $name = $name . '.' . $ext;
         $tmp = $_FILES['BookImage']['tmp_name']['url'];
         $productImage->url = $name;
         move_uploaded_file($tmp, '../uploads/' . $name);
     }
     if (!empty($_POST)) {
         $productImage->name = $_POST['BookImage']['name'];
         $productImage->product_id = $book_id;
         if ($productImage->save()) {
             $session = new Session();
             $session->open();
             $session->setFlash('message', 'Data Saved.');
             return $this->redirect(['index', 'book_id' => $book_id]);
         }
     }
     return $this->render('//BookImage/Form', ['product' => $product, 'productImage' => $productImage]);
 }
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:27,代码来源:BookImageController.php


示例5: loadModel

 /**
  * @param $id
  * @return null|Book
  * @throws NotFoundHttpException
  */
 private function loadModel($id)
 {
     $model = Book::findOne($id);
     if (null == $model) {
         throw new NotFoundHttpException('Книга не найдена');
     }
     return $model;
 }
开发者ID:dub34,项目名称:books-test,代码行数:13,代码来源:BooksController.php


示例6: loadModel

 private function loadModel($id)
 {
     $model = Book::find($id)->one();
     if (!$model) {
         throw new HttpException(404, 'Not Found');
     }
     return $model;
 }
开发者ID:virtyos,项目名称:books_manager,代码行数:8,代码来源:SiteController.php


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


示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('books')->truncate();
     $faker = \Faker\Factory::create();
     for ($count = 0; $count < 500; $count++) {
         Book::create(['title' => $faker->sentence(), 'desc' => $faker->text(), 'cover' => $faker->imageUrl()]);
     }
 }
开发者ID:aphiwadChhoeun,项目名称:Book-API,代码行数:13,代码来源:BookTableSeeder.php


示例9: actionDelete

 public function actionDelete($id)
 {
     $book = Book::findOne(['id' => $id]);
     if ($book) {
         $book->delete();
     }
     $this->redirect(Url::to(['books/index']));
 }
开发者ID:k666r,项目名称:test_yii2,代码行数:8,代码来源:BooksController.php


示例10: findModel

 protected function findModel($id)
 {
     if (($model = Book::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:vagrant200192,项目名称:traning,代码行数:8,代码来源:BookController.php


示例11: runJoinSearch

 public function runJoinSearch($i)
 {
     $book = Book::find()->from('Book b')->with('author')->where('b.title = :t', [':t' => 'Hello' . $i])->one();
     //        $book = $this->em->createQuery(
     //            'SELECT b, a FROM Book b JOIN b.author a WHERE b.title = ?1'
     //        )->setParameter(1, 'Hello' . $i)
     //         ->setMaxResults(1)
     //         ->getResult();
 }
开发者ID:motin,项目名称:forked-php-orm-benchmark,代码行数:9,代码来源:Yii2MTestSuite.php


示例12: actionDelete

 public function actionDelete()
 {
     $id = (int) Yii::$app->request->get('id');
     /** @var Book $book */
     $book = Book::findOne(['id' => $id]);
     $result = $book ? $book->delete() : false;
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['result' => (bool) $result];
 }
开发者ID:sedpro,项目名称:yii2-test-app,代码行数:9,代码来源:BookController.php


示例13: runJoinSearch

 public function runJoinSearch($i)
 {
     $book = \app\models\Book::find()->from('Book b')->with('author')->where('b.title = ?', ['Hello' . $i])->limit(1)->scalar();
     //        $book = $this->em->createQuery(
     //            'SELECT b, a FROM Book b JOIN b.author a WHERE b.title = ?1'
     //        )->setParameter(1, 'Hello' . $i)
     //         ->setMaxResults(1)
     //         ->getScalarResult();
 }
开发者ID:motin,项目名称:forked-php-orm-benchmark,代码行数:9,代码来源:YiiMScalarHydrateTestSuite.php


示例14: coverStore

 public function coverStore(Request $request, $id)
 {
     $book = Book::find($id);
     if (Gate::denies('manageBook', $book)) {
         abort(403, 'voce não é o dono desse livro');
     }
     $bookService = app()->make(BookService::class);
     $bookService->storeCover($book, $request->file('file'));
 }
开发者ID:phelipperibeiro,项目名称:book_store_laravel,代码行数:9,代码来源:BooksController.php


示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Book::truncate();
     $faker = Faker::create();
     for ($i = 1; $i <= 30; $i++) {
         Book::create(['title' => $faker->sentence(), 'description' => $faker->sentence(), 'author' => $faker->name]);
     }
 }
开发者ID:kongtoonarmy,项目名称:laravel-transformers,代码行数:15,代码来源:BooksTableSeeder.php


示例16: index

 function index()
 {
     $terbaru = Book::orderBy('BookID', 'desc')->skip(0)->take(6)->get();
     $data['categories'] = $this->categories;
     $data['terbaru'] = $terbaru;
     if (Auth::member() != null) {
         $data['member'] = Auth::member();
     }
     $this->view->render('home', $data);
     $this->view->data = "asu";
 }
开发者ID:blegoh,项目名称:Web,代码行数:11,代码来源:HomeController.php


示例17: actionIndex

 public function actionIndex()
 {
     $dataProvider = new ArrayDataProvider(['allModels' => Book::find()->orderBy('rank')->limit(3)->asArray()->all()]);
     //$test = Book::getDb()->cache(function($db){
     //    Book::find()->orderBy('rank');
     //});
     //$result = $db->cache(function ($db) {
     //    return $db->createCommand('SELECT * FROM user WHERE id=4')->queryOne();
     //});
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
开发者ID:scarneros,项目名称:yii2-tutorial,代码行数:11,代码来源:SiteController.php


示例18: search

 /**
  * Search for books
  *
  * @param string $terms
  * @param array $advancedQueries @see self::$advancedQueryOptions for more information
  * @param array $options @see self::$optionSettings for more information
  *
  * @return \App\Models\Book[]
  */
 public function search($terms, array $advancedQueries = [], $options = [])
 {
     if (!$this->areAdvancedQueriesValid($advancedQueries)) {
         return false;
     }
     $this->setDefaultOptions($options);
     $query = $this->book->order($options['orderBy'], $options['order'])->page($options['page'], $options['limit']);
     if ($terms) {
         $query->searchFor($terms);
     }
     foreach ($advancedQueries as $key => $value) {
         $method = $this->advanceQuerySettings[$key]['method'];
         if ($key === 'range') {
             list($from, $to) = $value;
             $this->book->{$method}($from, $to);
         } else {
             $this->book->{$method}($value);
         }
     }
     return $query->get();
 }
开发者ID:MLoureiro,项目名称:book-api-trial,代码行数:30,代码来源:BookRepository.php


示例19: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $tolkien = Author::create(['name' => 'J.R.R. Tolkien', 'date_of_birth' => '1892-01-03']);
     Book::create(['title' => 'The Hobbit', 'publication_date' => '1937-09-21', 'isbn' => '9780582186552', 'author_id' => $tolkien->id]);
     Book::create(['title' => 'The Silmarillion', 'publication_date' => '1977-09-15', 'isbn' => '9780345325815', 'author_id' => $tolkien->id]);
     $karpyshyn = Author::create(['name' => 'Drew Karpyshyn', 'date_of_birth' => '1971-07-28']);
     Book::create(['title' => 'The Old Republic: Revan', 'publication_date' => '2011-11-15', 'isbn' => '9780857689009', 'author_id' => $karpyshyn->id]);
     Book::create(['title' => 'The Old Republic: Annihilation', 'publication_date' => '2012-11-13', 'isbn' => '9780345529411', 'author_id' => $karpyshyn->id]);
     $salvatore = Author::create(['name' => 'R.A. Salvatore', 'date_of_birth' => '1959-01-20']);
     Book::create(['title' => 'Homeland', 'publication_date' => '2004-03-01', 'isbn' => '9780786931231', 'author_id' => $salvatore->id]);
     Book::create(['title' => 'Attack of the Clones', 'publication_date' => '2003-04-01', 'isbn' => '9780345428820', 'author_id' => $salvatore->id]);
 }
开发者ID:simonbacquie,项目名称:get-started-with-lumen,代码行数:17,代码来源:SampleDataSeeder.php


示例20: create

 public function create($request)
 {
     \DB::beginTransaction();
     $user = \Auth::user();
     $book = Book::create($request->all());
     $book->product()->create($request->all());
     $book->product->organizations()->attach($user->organization->id, ['dewey_code' => $request['dewey_code'], 'quantity' => $request['quantity'], 'cat_id' => $request['cat_id'], 'user_id' => $user->id, 'edited_by' => $user->id]);
     $book->authors()->attach($request['author-list']);
     $item = Item::find($book->product->orgcreate()->first()->pivot->id);
     $item->tags()->attach($request['tag-list']);
     \DB::commit();
 }
开发者ID:nicsmyrn,项目名称:library,代码行数:12,代码来源:DbBookRepository.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP models\Books类代码示例发布时间:2022-05-23
下一篇:
PHP models\BaseModel类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap