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


PHP Author::create方法代码示例

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


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

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

示例2: addNewAuthor

 public function addNewAuthor($request)
 {
     $data = array();
     $rules = ['firstname' => 'alpha', 'lastname' => 'required|min:3|alpha'];
     $messages = ['lastname.required' => 'Το επώνυμο του συγγραφέα είναι υποχρεωτικό', 'lastname.min' => 'Το επώνυμο του συγγραφέα  πρέπει να είναι τουλάχιστον 3 χαρακτήρες', 'lastname.alpha' => 'Το επώνυμο του συγγραφέα  πρέπει να είναι Αγγλικοί ή Ελληνικοί χαρακτήρες', 'firstname.alpha' => 'Το όνομα του συγγραφέα πρέπει να είναι Αγγλικοί ή Ελληνικοί χαρακτήρες'];
     if ($request->ajax()) {
         $validator = \Validator::make($request->all(), $rules, $messages);
         if ($validator->fails()) {
             return \Response::json($validator->errors()->all(), 422);
         } else {
             $author = Author::create(['lastname' => Str::upper($request->get('lastname')), 'firstname' => Str::upper($request->get('firstname'))]);
             if ($author) {
                 $data['sweetalert'] = ['title' => 'Συγχαρητήρια', 'body' => 'ο συγγραφέας προστέθηκε με επιτυχία', 'level' => 'success'];
                 $data['author']['lastname'] = $author->lastname;
                 $data['author']['firstname'] = $author->firstname;
                 $data['author']['id'] = $author->id;
             } else {
                 $data['sweetalert'] = ['title' => 'Πρόβλημα', 'body' => 'ο συγγραφέας ΔΕΝ  αποθηκεύτηκε...', 'level' => 'error'];
             }
             return \Response::json($data);
         }
     }
 }
开发者ID:nicsmyrn,项目名称:library,代码行数:23,代码来源:AjaxBookRepository.php

示例3: import

 public function import()
 {
     /*   $dataJson = $this->readJson('TlgProfile.json');
          foreach ($dataJson['results'] as $key => $data) {
              $data['tlg_group_logo'] = isset($data['tlg_group_logo']) ? $data['tlg_group_logo']['url'] : '';
              $data['tlg_leader_img'] = isset($data['tlg_leader_img']) ? $data['tlg_leader_img']['url'] : '';
              $data['tlg_member_ph'] = isset($data['tlg_member_ph']) ? json_encode($data['tlg_member_ph']) : '';
              TlgProfile::create($data);
          }
          $dataJson = $this->readJson('Post.json');
          foreach ($dataJson['results'] as $key => $data) {
              $data['image'] = isset($data['image']) ? $data['image']['url'] : '';
              $data['postUploadedDate'] = isset($data['postUploadedDate']) ? $data['postUploadedDate']['iso'] : '';
              $data['userId'] = isset($data['userId']) ? $data['userId']['objectId'] : '';
              Post::create($data);
          }*/
     $dataJson = $this->readJson('IwomenPost.json');
     foreach ($dataJson['results'] as $key => $data) {
         $data['image'] = isset($data['image']) ? $data['image']['url'] : '';
         $data['postUploadedDate'] = isset($data['postUploadedDate']) ? $data['postUploadedDate']['iso'] : '';
         $data['userId'] = isset($data['userId']) ? $data['userId']['objectId'] : '';
         $data['authorId'] = isset($data['authorId']) ? $data['authorId']['objectId'] : '';
         $data['postUploadPersonImg'] = isset($data['postUploadPersonImg']) ? $data['postUploadPersonImg']['url'] : '';
         $data['audioFile'] = isset($data['audioFile']) ? $data['audioFile']['url'] : '';
         IwomenPost::create($data);
     }
     $dataJson = $this->readJson('Resources.json');
     foreach ($dataJson['results'] as $key => $data) {
         $data['resource_icon_img'] = isset($data['resource_icon_img']) ? $data['resource_icon_img']['url'] : '';
         Resources::create($data);
     }
     $dataJson = $this->readJson('Author.json');
     foreach ($dataJson['results'] as $key => $data) {
         $data['authorImg'] = isset($data['authorImg']) ? $data['authorImg']['url'] : '';
         Author::create($data);
     }
     /*
             $dataJson = $this->readJson('Comment.json');
             foreach ($dataJson['results'] as $key => $data) {
                 $data['comment_created_time'] = isset($data['comment_created_time']) ? $data['comment_created_time']['iso'] : '';
                 $data['postId'] = isset($data['postId']) ? $data['postId']['objectId'] : '';
                 $data['userId'] = isset($data['userId']) ? $data['userId']['objectId'] : '';
                 Comment::create($data);
             }*/
     $dataJson = $this->readJson('SubResourceDetail.json');
     foreach ($dataJson['results'] as $key => $data) {
         $data['author_id'] = isset($data['author_id']) ? $data['author_id']['objectId'] : '';
         $data['posted_date'] = isset($data['posted_date']) ? $data['posted_date']['iso'] : '';
         $data['resource_id'] = isset($data['resource_id']) ? $data['resource_id']['objectId'] : '';
         SubResourceDetail::create($data);
     }
     /*
             $dataJson = $this->readJson('SisterDownloadApp.json');
             foreach ($dataJson['results'] as $key => $data) {
                 $data['app_img'] = isset($data['app_img']) ? $data['app_img']['url'] : '';
                 SisterDownloadApp::create($data);
             }
             $dataJson = $this->readJson('StickerStore.json');
             foreach ($dataJson['results'] as $key => $data) {
                 $data['stickerImg'] = isset($data['stickerImg']) ? $data['stickerImg']['url'] : '';
                 StickerStore::create($data);
             }
             $dataJson = $this->readJson('User.json');
             foreach ($dataJson['results'] as $key => $data) {
                 $data['password'] = isset($data['bcryptPassword']) ? $data['bcryptPassword'] : '';
                 $data['user_profile_img'] = isset($data['user_profile_img']) ? $data['user_profile_img']['url'] : '';
                 $data['profileimage'] = isset($data['profileimage']) ? $data['profileimage']['url'] : '';
                 User::create($data);
             }*/
     return response()->json('success');
 }
开发者ID:SawMaineK,项目名称:iwomenapp,代码行数:71,代码来源:HomeController.php


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