本文整理汇总了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']);
}
示例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'));
}
示例3: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Author::create([]);
}
}
示例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);
}
示例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 <b>earth</b></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);
}
示例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')]);
}
}
示例7: run
public function run()
{
$faker = Faker::create();
Author::truncate();
foreach (range(1, 5) as $index) {
Author::create(['name' => $faker->name]);
}
}
示例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}");
}
示例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);
}
示例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.');
}
}
示例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'));
示例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());
}
示例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));
}
示例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);
}
}
示例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);
}