本文整理匯總了PHP中Article::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::create方法的具體用法?PHP Article::create怎麽用?PHP Article::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Article
的用法示例。
在下文中一共展示了Article::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Article::create([]);
}
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Article::create(['title' => $faker->sentence($nbWords = 6), 'body' => $faker->paragraph($nbSentences = 5), 'user_id' => 1]);
}
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /article
*
* @return Response
*/
public function store()
{
$rules = ['title' => 'required|max:100', 'content' => 'required', 'tags' => array('required', 'regex:/^\\w+$|^(\\w+,)+\\w+$/')];
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$article = Article::create(Input::only('title', 'content'));
$article->user_id = Auth::id();
$resolved_content = Markdown::parse(Input::get('content'));
$article->resolved_content = $resolved_content;
$tags = array_unique(explode(',', Input::get('tags')));
if (str_contains($resolved_content, '<p>')) {
$start = strpos($resolved_content, '<p>');
$length = strpos($resolved_content, '</p>') - $start - 3;
$article->summary = substr($resolved_content, $start + 3, $length);
} elseif (str_contains($resolved_content, '</h')) {
$start = strpos($resolved_content, '<h');
$length = strpos($resolved_content, '</h') - $start - 4;
$article->summary = substr($resolved_content, $start + 4, $length);
}
$article->save();
foreach ($tags as $tagName) {
$tag = Tag::whereName($tagName)->first();
if (!$tag) {
$tag = Tag::create(array('name' => $tagName));
}
$tag->count++;
$article->tags()->save($tag);
}
return Redirect::route('article.show', $article->id);
} else {
return Redirect::route('article.create')->withInput()->withErrors($validator);
}
}
示例4: create_object
public function create_object($data)
{
try {
$mc = new \Core\Backend\MemcachedContainer();
$m = $mc->get_backend();
$m_enable = True;
} catch (\Core\Backend\MemcachedNotLoadedError $e) {
}
$data = \Core\Dict::create($data);
if (strlen($data->custom_url) > 0) {
$data->seo_title = $data->custom_url;
} else {
$data->seo_title = strtolower(str_replace(' ', '-', $data->title));
}
if (extension_loaded('discount')) {
$md = \MarkdownDocument::createFromString($data['body']);
$md->compile();
$data['body_html'] = $md->getHtml();
} else {
import('3rdparty.markdown');
$data['body_html'] = Markdown($data['body']);
}
$data->preview = substr(strip_tags($data['body_html']), 0, 440);
$a = Article::create($data)->form_values();
return $a;
}
示例5: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Article::create(['title' => $faker->sentence(), 'body' => $faker->realText(1000), 'user_id' => rand(1, 5)]);
}
}
示例6: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Article::create(['title' => $faker->sentence($nbWords = 6), 'slug' => 'first-post']);
}
}
示例7: store
/**
* Store a newly created article in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Article::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Article::create($data);
return Redirect::route('admin.articles.index');
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(UserRequest $request)
{
$input = $request->all();
$article = Article::create(['title' => $input['titolo'], 'text' => $input['Descrizione']]);
if ($request->ajax() || $request->wantsJson()) {
return new JsonResponse($article);
}
flash()->success('salvato con successo!');
return redirect('article');
}
示例9: store
public function store(Requests\CreateArticleRequest $request)
{
// $input = Request::all();
// $input['published_at'] = Carbon::now();
// Article::create($input);
Article::create(Request::all());
//This equals Request::all() but more compact because Article::create now contains Request::all()
//The browser is now being redirected to the articles (in this case articles.index) view
return redirect('articles');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$data = Input::get('data');
$article = \Article::create($data);
if ($article->id) {
return Redirect::route('admin.article.index');
} else {
return Msgbox::error($article->getLastError() ?: "創建文章失敗");
}
}
示例11: run
public function run()
{
$i = 0;
for ($i = 0; $i < 60; $i++) {
Article::create(['title' => '圈子話題' . $i, 'scan_num' => 912, 'join_num' => 212, 'focus_num' => 1334, 'hot_offical' => $i > 30 ? 1 : 0]);
}
// Article::create([
// 'title' => '圈子話題2',
// 'scan_num' => 33,
// 'join_num' => 3333,
// 'focus_num' => 1234
// ]);
// Article::create([
// 'title' => '圈子話題3',
// 'scan_num' => 912,
// 'join_num' => 212,
// 'focus_num' => 1334
// ]);
// Article::create([
// 'title' => '圈子話題4',
// 'scan_num' => 33,
// 'join_num' => 3333,
// 'focus_num' => 1234
// ]);
// Article::create([
// 'title' => '圈子話題5',
// 'scan_num' => 912,
// 'join_num' => 212,
// 'focus_num' => 1334
// ]);
// Article::create([
// 'title' => '圈子話題6',
// 'scan_num' => 33,
// 'join_num' => 3333,
// 'focus_num' => 1234
// ]);
// Article::create([
// 'title' => '圈子話題7',
// 'scan_num' => 912,
// 'join_num' => 212,
// 'focus_num' => 1334
// ]);
// Article::create([
// 'title' => '圈子話題8',
// 'scan_num' => 33,
// 'join_num' => 3333,
// 'focus_num' => 1234
// ]);
}
示例12: publish
/**
* Publish entry
*
* @param Newscoop\Entity\Ingest\Feed\Entry $entry
* @param string $status
* @return Article
*/
public function publish(Entry $entry, $status = 'Y')
{
$article = new \Article($this->getLanguage($entry->getLanguage()));
$article->create($this->config['article_type'], $entry->getTitle(), $this->getPublication(), $this->getIssue(), $this->getSection($entry));
$article->setWorkflowStatus(strpos($entry->getTitle(), self::PROGRAM_TITLE) === 0 ? 'N' : $status);
$article->setKeywords($entry->getCatchWord());
$article->setCommentsEnabled(TRUE);
$this->setArticleData($article, $entry);
$this->setArticleDates($article, $entry);
$this->setArticleAuthors($article, $entry);
$this->setArticleImages($article, $entry->getImages());
$entry->setArticleNumber($article->getArticleNumber());
$article->commit();
return $article;
}
示例13: seedArticle
/**
* 填充文章數據
* @return void
*/
private function seedArticle()
{
for ($i = 1; $i < 30; $i++) {
Article::create(array('category_id' => 2 + $i % 4, 'user_id' => $i, 'title' => '標題' . $i, 'slug' => 'slug-biao-ti-' . $i, 'content' => $this->generateArticleContent($i)));
}
$this->command->info('隨機文章數據填充完畢');
sleep(1);
Article::create(array('category_id' => 2, 'user_id' => 1, 'title' => 'PSR-0 自動加載規範', 'slug' => 'psr-0', 'content' => File::get(__DIR__ . '/PSR/PSR-0.md')));
sleep(1);
Article::create(array('category_id' => 2, 'user_id' => 1, 'title' => 'PSR-1 基礎編碼規範', 'slug' => 'psr-1-basic-coding-standard', 'content' => File::get(__DIR__ . '/PSR/PSR-1-basic-coding-standard.md')));
sleep(1);
Article::create(array('category_id' => 2, 'user_id' => 1, 'title' => 'PSR-2 編碼風格規範', 'slug' => 'psr-2-coding-style-guide', 'content' => File::get(__DIR__ . '/PSR/PSR-2-coding-style-guide.md')));
sleep(1);
Article::create(array('category_id' => 2, 'user_id' => 1, 'title' => 'PSR-3 日誌接口規範', 'slug' => 'psr-3-logger-interface', 'content' => File::get(__DIR__ . '/PSR/PSR-3-logger-interface.md')));
$this->command->info('PSR 係列文章數據填充完畢');
}
示例14: run
public function run()
{
DB::table('articles')->delete();
/*
Assumes:
"published" has status_id = 1
"draft" has status_id = 2
"author" has user_id = 1
*/
Article::create(array('user_id' => 1, 'status_id' => 1, 'title' => 'My first article', 'slug' => 'my-first-article', 'excerpt' => 'This is my first article, and here is a short description of it! Tally-ho!', 'content' => "This will be parsed as markdown and so needs some line-breaks.\n\n## A h2 headline\nThe content under-which is about the H2 headline, because Google knows everything about SEO and tells you have to build your html."));
Article::create(array('user_id' => 1, 'status_id' => 1, 'title' => 'My second article', 'slug' => 'my-second-article', 'excerpt' => 'This is my second article, and here is a short description of said second article!', 'content' => "Synth nulla Banksy, sriracha odio ennui forage artisan keytar DIY. Meggings accusamus proident, meh ugh PBR single-origin coffee 3 wolf moon cliche twee dreamcatcher.\n\n## Laborum thundercats gluten-free\nTerry Richardson ex semiotics mixtape wolf sunt proident salvia. Church-key Banksy bitters, ex mollit exercitation bicycle rights chambray gluten-free quis aute sriracha forage flexitarian vero."));
Article::create(array('user_id' => 1, 'status_id' => 1, 'title' => 'My third article', 'slug' => 'my-third-article', 'excerpt' => 'This is my third article, and here is a short description of said third article!', 'content' => "Bacon ipsum dolor sit amet pork belly meatloaf ham hock jerky short ribs pastrami brisket ball tip swine ham fatback capicola spare ribs shank.\n\n## Pancetta short ribs\nPancetta jerky pork loin tenderloin, drumstick strip steak pork belly spare ribs fatback. Strip steak tongue sirloin pancetta tenderloin, ground round fatback sausage. Flank tenderloin beef shank jerky ham chuck jowl chicken. Kielbasa tenderloin beef ribs, capicola ham pancetta turducken shankle filet mignon pork loin."));
Article::create(array('user_id' => 1, 'status_id' => 1, 'title' => 'My fourth article', 'slug' => 'my-fourth-article', 'excerpt' => 'This is my fourth article, and here is a short description of said fourth article!', 'content' => "Cliche quinoa swag roof party sartorial american apparel. Helvetica Brooklyn chambray PBR, intelligentsia scenester cupidatat 3 wolf moon food truck elit Pinterest ullamco master cleanse.\n\nMeh YOLO put a bird on it velit, minim banh mi non thundercats vegan enim sapiente irure assumenda photo booth. Aute Tonx flannel blog retro McSweeney's. Salvia ennui eu, fingerstache pickled blog twee minim polaroid authentic Brooklyn mixtape."));
Article::create(array('user_id' => 1, 'status_id' => 2, 'title' => 'My greatest life achievement', 'slug' => 'my-greatest-life-achievement', 'excerpt' => "IT'S STILL A DRAFT! I HAVEN'T AHCIEVED ANYTHING!!!! I'VE FAILED AT YOLOING.", 'content' => "This is the story of a man, who is afraid. But then he just *crushes it* hardcore."));
}
示例15: run
public function run()
{
DB::table('articles')->delete();
Article::create(array('title' => 'Robots helped inspire deep learning might become.', 'slug' => 'Robots-helped-inspire-deep-learning-might-become', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum imperdiet nisi, feugiat facilisis ex pretium a. Nulla nec justo ipsum. In hac habitasse platea dictumst. Nunc eu tortor vitae diam sodales ultrices. Quisque sed elit et mauris vulputate rhoncus. Nam erat eros, vehicula sed nunc at, aliquet finibus magna. Duis suscipit odio vitae vulputate bibendum. Phasellus non neque quis odio congue mattis. Duis ullamcorper arcu magna, sit amet pretium urna pretium eget. Duis lectus leo, auctor id euismod commodo, ultrices vitae orci. Sed sit amet massa eget sem suscipit dictum placerat in magna. Integer ut nibh mauris. Maecenas turpis quam, vehicula sit amet sagittis eu, egestas non justo. Maecenas magna massa, tristique vel sagittis et, aliquam non nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum et nisl porttitor, auctor magna non, vestibulum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet dolor luctus, accumsan enim id, condimentum eros. Aliquam sed convallis lacus. Vestibulum in venenatis est, vitae tempor libero. In porttitor nulla nec mi sagittis fermentum. Curabitur erat lacus, aliquam at vulputate facilisis, egestas nec dui. Nullam ac lorem ipsum. Curabitur ac libero sed turpis rutrum tempus ac faucibus leo.
Phasellus ac aliquam turpis. Fusce vestibulum eleifend varius. Nunc pharetra posuere elit, eu convallis eros condimentum sed. Pellentesque orci sapien, semper sed dolor ac, euismod pellentesque velit. Duis blandit purus ac odio mattis sollicitudin. Suspendisse tortor nisl, euismod at nulla et, ullamcorper dignissim eros. Vivamus a vestibulum risus.', 'admin_id' => DB::table('admins')->select('id')->where('username', 'admin')->first()->id, 'category_id' => DB::table('categories')->select('id')->where('category', 'Programming')->first()->id));
Article::create(array('title' => 'Man agrees to complete $50,000 Hereford Inlet Lighthouse paint job.', 'slug' => 'Man-agrees-to-complete-$50,000-Hereford-Inlet-Lighthouse-paint-job', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum imperdiet nisi, feugiat facilisis ex pretium a. Nulla nec justo ipsum. In hac habitasse platea dictumst. Nunc eu tortor vitae diam sodales ultrices. Quisque sed elit et mauris vulputate rhoncus. Nam erat eros, vehicula sed nunc at, aliquet finibus magna. Duis suscipit odio vitae vulputate bibendum. Phasellus non neque quis odio congue mattis. Duis ullamcorper arcu magna, sit amet pretium urna pretium eget. Duis lectus leo, auctor id euismod commodo, ultrices vitae orci. Sed sit amet massa eget sem suscipit dictum placerat in magna. Integer ut nibh mauris. Maecenas turpis quam, vehicula sit amet sagittis eu, egestas non justo. Maecenas magna massa, tristique vel sagittis et, aliquam non nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum et nisl porttitor, auctor magna non, vestibulum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet dolor luctus, accumsan enim id, condimentum eros. Aliquam sed convallis lacus. Vestibulum in venenatis est, vitae tempor libero. In porttitor nulla nec mi sagittis fermentum. Curabitur erat lacus, aliquam at vulputate facilisis, egestas nec dui. Nullam ac lorem ipsum. Curabitur ac libero sed turpis rutrum tempus ac faucibus leo.
Phasellus ac aliquam turpis. Fusce vestibulum eleifend varius. Nunc pharetra posuere elit, eu convallis eros condimentum sed. Pellentesque orci sapien, semper sed dolor ac, euismod pellentesque velit. Duis blandit purus ac odio mattis sollicitudin. Suspendisse tortor nisl, euismod at nulla et, ullamcorper dignissim eros. Vivamus a vestibulum risus.', 'admin_id' => DB::table('admins')->select('id')->where('username', 'admin')->first()->id, 'category_id' => DB::table('categories')->select('id')->where('category', 'Programming')->first()->id));
Article::create(array('title' => 'Microsoft Subsumes Open Tech Unit Back Inside Mothership.', 'slug' => 'Microsoft-Subsumes-Open-Tech-Unit-Back-Inside-Mothership', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum imperdiet nisi, feugiat facilisis ex pretium a. Nulla nec justo ipsum. In hac habitasse platea dictumst. Nunc eu tortor vitae diam sodales ultrices. Quisque sed elit et mauris vulputate rhoncus. Nam erat eros, vehicula sed nunc at, aliquet finibus magna. Duis suscipit odio vitae vulputate bibendum. Phasellus non neque quis odio congue mattis. Duis ullamcorper arcu magna, sit amet pretium urna pretium eget. Duis lectus leo, auctor id euismod commodo, ultrices vitae orci. Sed sit amet massa eget sem suscipit dictum placerat in magna. Integer ut nibh mauris. Maecenas turpis quam, vehicula sit amet sagittis eu, egestas non justo. Maecenas magna massa, tristique vel sagittis et, aliquam non nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum et nisl porttitor, auctor magna non, vestibulum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet dolor luctus, accumsan enim id, condimentum eros. Aliquam sed convallis lacus. Vestibulum in venenatis est, vitae tempor libero. In porttitor nulla nec mi sagittis fermentum. Curabitur erat lacus, aliquam at vulputate facilisis, egestas nec dui. Nullam ac lorem ipsum. Curabitur ac libero sed turpis rutrum tempus ac faucibus leo.
Phasellus ac aliquam turpis. Fusce vestibulum eleifend varius. Nunc pharetra posuere elit, eu convallis eros condimentum sed. Pellentesque orci sapien, semper sed dolor ac, euismod pellentesque velit. Duis blandit purus ac odio mattis sollicitudin. Suspendisse tortor nisl, euismod at nulla et, ullamcorper dignissim eros. Vivamus a vestibulum risus.', 'admin_id' => DB::table('admins')->select('id')->where('username', 'admin')->first()->id, 'category_id' => DB::table('categories')->select('id')->where('category', 'Programming')->first()->id));
Article::create(array('title' => 'Five things you may have missed over the weekend from the i dont know.', 'slug' => 'Five-things-you-may-have-missed-over-the-weekend-from-the-i-dont-know', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum imperdiet nisi, feugiat facilisis ex pretium a. Nulla nec justo ipsum. In hac habitasse platea dictumst. Nunc eu tortor vitae diam sodales ultrices. Quisque sed elit et mauris vulputate rhoncus. Nam erat eros, vehicula sed nunc at, aliquet finibus magna. Duis suscipit odio vitae vulputate bibendum. Phasellus non neque quis odio congue mattis. Duis ullamcorper arcu magna, sit amet pretium urna pretium eget. Duis lectus leo, auctor id euismod commodo, ultrices vitae orci. Sed sit amet massa eget sem suscipit dictum placerat in magna. Integer ut nibh mauris. Maecenas turpis quam, vehicula sit amet sagittis eu, egestas non justo. Maecenas magna massa, tristique vel sagittis et, aliquam non nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum et nisl porttitor, auctor magna non, vestibulum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet dolor luctus, accumsan enim id, condimentum eros. Aliquam sed convallis lacus. Vestibulum in venenatis est, vitae tempor libero. In porttitor nulla nec mi sagittis fermentum. Curabitur erat lacus, aliquam at vulputate facilisis, egestas nec dui. Nullam ac lorem ipsum. Curabitur ac libero sed turpis rutrum tempus ac faucibus leo.
Phasellus ac aliquam turpis. Fusce vestibulum eleifend varius. Nunc pharetra posuere elit, eu convallis eros condimentum sed. Pellentesque orci sapien, semper sed dolor ac, euismod pellentesque velit. Duis blandit purus ac odio mattis sollicitudin. Suspendisse tortor nisl, euismod at nulla et, ullamcorper dignissim eros. Vivamus a vestibulum risus.', 'admin_id' => DB::table('admins')->select('id')->where('username', 'admin')->first()->id, 'category_id' => DB::table('categories')->select('id')->where('category', 'Operating Systems')->first()->id));
Article::create(array('title' => 'Announcing a specification for PHP.', 'slug' => 'Announcing-a-specification-for-PHP', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris bibendum imperdiet nisi, feugiat facilisis ex pretium a. Nulla nec justo ipsum. In hac habitasse platea dictumst. Nunc eu tortor vitae diam sodales ultrices. Quisque sed elit et mauris vulputate rhoncus. Nam erat eros, vehicula sed nunc at, aliquet finibus magna. Duis suscipit odio vitae vulputate bibendum. Phasellus non neque quis odio congue mattis. Duis ullamcorper arcu magna, sit amet pretium urna pretium eget. Duis lectus leo, auctor id euismod commodo, ultrices vitae orci. Sed sit amet massa eget sem suscipit dictum placerat in magna. Integer ut nibh mauris. Maecenas turpis quam, vehicula sit amet sagittis eu, egestas non justo. Maecenas magna massa, tristique vel sagittis et, aliquam non nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum et nisl porttitor, auctor magna non, vestibulum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sit amet dolor luctus, accumsan enim id, condimentum eros. Aliquam sed convallis lacus. Vestibulum in venenatis est, vitae tempor libero. In porttitor nulla nec mi sagittis fermentum. Curabitur erat lacus, aliquam at vulputate facilisis, egestas nec dui. Nullam ac lorem ipsum. Curabitur ac libero sed turpis rutrum tempus ac faucibus leo.
Phasellus ac aliquam turpis. Fusce vestibulum eleifend varius. Nunc pharetra posuere elit, eu convallis eros condimentum sed. Pellentesque orci sapien, semper sed dolor ac, euismod pellentesque velit. Duis blandit purus ac odio mattis sollicitudin. Suspendisse tortor nisl, euismod at nulla et, ullamcorper dignissim eros. Vivamus a vestibulum risus.', 'admin_id' => DB::table('admins')->select('id')->where('username', 'admin')->first()->id, 'category_id' => DB::table('categories')->select('id')->where('category', 'Programming')->first()->id));
}