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


PHP Author::create方法代码示例

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


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

示例1: run

 public function run()
 {
     DB::table('authors')->delete();
     Author::create(['name' => 'Lauren', 'surname' => 'Oliver']);
     Author::create(['name' => 'Stephenie', 'surname' => 'Meyer']);
     Author::create(['name' => 'Dan', 'surname' => 'Brown']);
 }
开发者ID:ngeshlew,项目名称:laravel-e-commerce-book-store,代码行数:7,代码来源:AuthorsTableSeeder.php

示例2: up

 public function up()
 {
     // DB::table('authors')->delete();
     Author::create(array('name' => 'Lauren', 'surname' => 'Olivier'));
     Author::create(array('name' => 'Stephenie', 'surname' => 'Meyer'));
     Author::create(array('name' => 'Dan', 'surname' => 'Brown'));
 }
开发者ID:jgbneatdesign,项目名称:kg,代码行数:7,代码来源:AuthorsTableSeeder.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Author::create([]);
     }
 }
开发者ID:Defoncesko,项目名称:iamhungry,代码行数:7,代码来源:AuthorsTableSeeder.php

示例4: testRenderAuthorWithTwitter

 public function testRenderAuthorWithTwitter()
 {
     $author = Author::create()->withURL('http://twitter.com/evertonrosario')->withName('Everton Rosario')->withDescription('Passionate coder and mountain biker');
     $expected = '<address>' . '<a href="http://twitter.com/evertonrosario">Everton Rosario</a>' . 'Passionate coder and mountain biker' . '</address>';
     $rendered = $author->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:7,代码来源:AuthorTest.php

示例5: testIsRTLEnabled

 public function testIsRTLEnabled()
 {
     $article = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->enableRTL()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $result = $article->render();
     $expected = '<!doctype html>' . '<html dir="rtl">' . '<head>' . '<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="1.5.2"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<header>' . '<h1>Peace on &lt;b&gt;earth&lt;/b&gt;</h1>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<address>' . '<a>bill</a>' . '</address>' . '</header>' . '<p>Yes, peace is good for everybody!<br/> Man kind.</p>' . '</article>' . '</body>' . '</html>';
     $this->assertEquals($expected, $result);
 }
开发者ID:facebook,项目名称:facebook-instant-articles-sdk-php,代码行数:7,代码来源:InstantArticleTest.php

示例6: run

 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 40) as $index) {
         $username = $faker->userName;
         Author::create(['name' => $username, 'deck' => $faker->sentence(12), 'website' => $faker->url, 'donate_link' => $faker->url, 'bio' => $faker->paragraph(5), 'slug' => Str::slug($username), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     }
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:8,代码来源:AuthorsSeeder.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     Author::truncate();
     foreach (range(1, 5) as $index) {
         Author::create(['name' => $faker->name]);
     }
 }
开发者ID:ryanda,项目名称:larapus,代码行数:8,代码来源:AuthorsTableSeeder.php

示例8: store

 public function store()
 {
     $validator = Validator::make($data = Input::all(), Author::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withPesan('Terdapat kesalahan validasi')->withInput();
     }
     $author = Author::create($data);
     return Redirect::route('admin.authors.index')->withPesan("Berhasil menyimpan {$author->name}");
 }
开发者ID:ryanda,项目名称:larapus,代码行数:9,代码来源:AuthorsController.php

示例9: testCompleteHeader

 public function testCompleteHeader()
 {
     date_default_timezone_set('UTC');
     $inline = '<script>alert("test & more test");</script>';
     $header = Header::create()->withTitle('Big Top Title')->withSubTitle('Smaller SubTitle')->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00')))->withModifyTime(Time::create(Time::MODIFIED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '10-Feb-2016 10:00:00')))->addAuthor(Author::create()->withName('Author One')->withDescription('Passionate coder and mountain biker'))->addAuthor(Author::create()->withName('Author Two')->withDescription('Weend surfer with heavy weight coding skils')->withURL('http://facebook.com/author'))->withKicker('Some kicker of this article')->withCover(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image')))->addAd(Ad::create()->withSource('http://foo.com'))->addAd(Ad::create()->withSource('http://foo.com')->withWidth(350)->withHeight(50)->enableDefaultForReuse())->addAd(Ad::create()->withWidth(300)->withHeight(250)->enableDefaultForReuse()->withHTML($inline));
     $expected = '<header>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '<figcaption>Some caption to the image</figcaption>' . '</figure>' . '<h1>Big Top Title</h1>' . '<h2>Smaller SubTitle</h2>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<time class="op-modified" datetime="2016-02-10T10:00:00+00:00">February 10th, 10:00am</time>' . '<address>' . '<a>Author One</a>' . 'Passionate coder and mountain biker' . '</address>' . '<address>' . '<a href="http://facebook.com/author" rel="facebook">Author Two</a>' . 'Weend surfer with heavy weight coding skils' . '</address>' . '<h3 class="op-kicker">Some kicker of this article</h3>' . '<section class="op-ad-template">' . '<figure class="op-ad">' . '<iframe src="http://foo.com"></iframe>' . '</figure>' . '<figure class="op-ad op-ad-default">' . '<iframe src="http://foo.com" width="350" height="50"></iframe>' . '</figure>' . '<figure class="op-ad">' . '<iframe width="300" height="250">' . '<script>alert("test & more test");</script>' . '</iframe>' . '</figure>' . '</section>' . '</header>';
     $rendered = $header->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:9,代码来源:HeaderTest.php

示例10: postCreate

 public function postCreate()
 {
     $validation = Author::validate(Input::all());
     if ($validation->fails()) {
         return Redirect::route('new_author')->withErrors($validation)->withInput();
     } else {
         Author::create(array('name' => Input::get('name'), 'bio' => Input::get('bio')));
         return Redirect::route('authors')->with('message', 'Author was created successfuly.');
     }
 }
开发者ID:ericbenwa,项目名称:laravel-test,代码行数:10,代码来源:AuthorsController.php

示例11: array

        camp_html_add_msg($translator->trans('Cannot remove author alias.', array(), 'users'));
    }
}
$first_name = Input::Get('first_name');
$last_name = Input::Get('last_name');
$can_save = false;
if ($id > -1 && strlen($first_name) > 0 && strlen($last_name) > 0) {
    $can_save = true;
}
if ($can_save) {
    $author = new Author();
    if ($id > 0) {
        $author = new Author($id);
        $isNewAuthor = false;
    } else {
        $author->create(array('first_name' => $first_name, 'last_name' => $last_name));
        $isNewAuthor = true;
    }
    $uploadFileSpecified = isset($_FILES['file']) && isset($_FILES['file']['name']) && !empty($_FILES['file']['name']);
    $author->setFirstName($first_name);
    $author->setLastName($last_name);
    $author->commit();
    // Reset types
    $types = Input::Get('type', 'array', array());
    AuthorAssignedType::ResetAuthorAssignedTypes($author->getId());
    foreach ($types as $type) {
        $author->setType($type);
    }
    $author->setSkype(Input::Get('skype'));
    $author->setJabber(Input::Get('jabber'));
    $author->setAim(Input::Get('aim'));
开发者ID:kartoffelkage,项目名称:Newscoop,代码行数:31,代码来源:authors.php

示例12: test_transaction_rolledback_by_throwing_exception

 public function test_transaction_rolledback_by_throwing_exception()
 {
     $original = Author::count();
     $exception = null;
     try {
         Author::transaction(function () {
             Author::create(array("name" => "blah"));
             throw new Exception("blah");
         });
     } catch (Exception $e) {
         $exception = $e;
     }
     $this->assert_not_null($exception);
     $this->assert_equals($original, Author::count());
 }
开发者ID:sebcode,项目名称:php-activerecord,代码行数:15,代码来源:ActiveRecordTest.php

示例13: test_inserting_with_explicit_pk

 public function test_inserting_with_explicit_pk()
 {
     $author = Author::create(array('author_id' => 9999, 'name' => 'blah'));
     $this->assert_not_null(Author::find($author->id));
 }
开发者ID:scorplev,项目名称:php-activerecord,代码行数:5,代码来源:ActiveRecordWriteTest.php

示例14: setArticleAuthorsLegacy

 /**
  * Set authors for an article, uses legacy classes
  *
  * @param Article                                   $article
  * @param \Newscoop\IngestPluginBundle\Entity\Entry $entry
  */
 protected function setArticleAuthorsLegacy(\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry)
 {
     $authors = $entry->getAuthors();
     $order = 0;
     if (count($authors) > 0) {
         foreach ($authors as $author) {
             $name = trim($author['firstname'] . ' ' . $author['lastname']);
             $author = new \Author($name);
             if (!$author->exists()) {
                 $author->create();
             }
             $article->setAuthor($author, $order++);
         }
     } else {
         $name = $entry->getProduct() ?: $entry->getFeed()->getName();
         $author = new \Author($name);
         if (!$author->exists()) {
             $author->create();
         }
         $article->setAuthor($author);
     }
 }
开发者ID:riverans,项目名称:plugin-IngestPluginBundle,代码行数:28,代码来源:PublisherService.php

示例15: camp_set_author

function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors)
{
    $translator = \Zend_Registry::get('container')->getService('translator');
    $p_errors = array();
    $articles = Article::GetArticlesOfType($p_sourceField->getArticleType());
    foreach ($articles as $article) {
        $articleData = $article->getArticleData();
        $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName()));
        if (empty($authorName)) {
            continue;
        }
        $author = new Author($authorName);
        if (!$author->exists()) {
            if (!$author->create()) {
                $p_errors[] = $translator->trans('Unable to create author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
                continue;
            }
        }
        if (!$article->setAuthorId($author->getId())) {
            $p_errors[] = $translator->trans('Error setting the author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
            continue;
        }
    }
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $cacheService->clearNamespace('authors');
    $cacheService->clearNamespace('article');
    return count($p_errors);
}
开发者ID:kartoffelkage,项目名称:Newscoop,代码行数:28,代码来源:lib_campsite.php


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