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


PHP Post::create方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Post::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(4), 'publiced' => $faker->boolean()]);
     }
 }
开发者ID:CreativeKoen,项目名称:workflow,代码行数:12,代码来源:PostsTableSeeder.php

示例2: run

 public function run()
 {
     DB::table('posts')->delete();
     Post::create(['author' => 'Noah', 'email' => 'noah@email.com', 'subject' => 'This is great', 'body' => 'Hi everyone. Just testing out the API! This is wonderful!']);
     Post::create(['author' => 'Anonymous', 'email' => 'anon@email.com', 'subject' => 'I\'m not sure I like this', 'body' => 'This is the body of my post. It\'s great, isn\'t it?']);
     Post::create(['author' => 'NJFan', 'email' => 'nj@other.com', 'subject' => 'New Jersey', 'body' => 'New Jersey is a state in the United States of America.']);
 }
开发者ID:nmakow,项目名称:basic-rest-api,代码行数:7,代码来源:DatabaseSeeder.php

示例3: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $hashtag = $this->argument('hashtag');
     $GetterClass = '\\App\\Getters\\' . $this->argument('provider') . 'Getter';
     $TransformerClass = 'App\\Transformers\\' . $this->argument('provider') . 'Transformer';
     $getter = new $GetterClass();
     $this->info('Getting posts from ' . $this->argument('provider'));
     $posts = $getter->getList($this->argument('howmany'), $this->argument('hashtag'));
     // transform posts
     foreach ($posts as $key => $post) {
         $transformer = new $TransformerClass($post);
         $currentPost = $transformer->get();
         // store if it doesn't already exist
         if (!Post::has($currentPost['post_id'])) {
             // check if post is popular enough
             if ($this->argument('qualityThreshold')) {
                 if ($transformer->isPopular($this->argument('qualityThreshold'))) {
                     Post::create($currentPost);
                 }
             } else {
                 Post::create($currentPost);
             }
         }
     }
     // Cache last 50 posts
     $this->comment('Caching last fifty posts');
     $lastFiftyPosts = \App\Post::orderBy('date_published', 'DESC')->take(50)->get();
     Cache::put('lastFiftyPosts', $lastFiftyPosts, 5);
 }
开发者ID:aboustayyef,项目名称:ysn,代码行数:34,代码来源:getLatestPosts.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $regles = array('titre' => 'required|min:5|max:40', 'contenu' => 'required|min:200', 'chapo' => 'required|max:300', 'publie' => 'required', 'photo' => 'image');
     $validation = Validator::make(Request::all(), $regles);
     if ($validation->fails()) {
         return redirect()->back()->withErrors($validation)->withInput();
     } else {
         Request::input('publie') == 'oui' ? $publie = true : ($publie = false);
         $slug = Str::slug(Request::input('titre'));
         $photo = Input::file('photo');
         if ($photo != null && $photo->isValid()) {
             $destinationPath = public_path() . '\\uploads\\posts';
             // upload path
             $extension = $photo->getClientOriginalExtension();
             // getting image extension
             $fileName = uniqid('post' . $slug . '-') . '.' . $extension;
             // renameing image
             $uploadSuccess = $photo->move($destinationPath, $fileName);
             if ($uploadSuccess) {
                 $path = asset('uploads/posts') . '/' . $fileName;
             }
         } else {
             $photo = '';
         }
         $article = Post::create(['titre' => Request::input('titre'), 'contenu' => Request::input('contenu'), 'slug' => $slug, 'chapo' => Request::input('chapo'), 'publie' => $publie, 'photo' => $path]);
     }
     return redirect()->route('post.show', ['post' => $article->id]);
 }
开发者ID:Byosphere,项目名称:BikeCityzen,代码行数:33,代码来源:PostController.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create('fr_FR');
     foreach (range(1, 10) as $index) {
         Post::create(['user_id' => rand(1, 4), 'title' => $faker->sentence, 'body' => $faker->paragraph]);
     }
 }
开发者ID:nayed,项目名称:lab,代码行数:12,代码来源:PostsTableSeeder.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $field = new StdClass();
     $field->type = "text";
     $field->name = "indredient1";
     $field->title = "Ingredient 1";
     $field->description = "Dit is de omschrijving";
     $field->validation = "required";
     $field->value = "Appels";
     $field1 = new StdClass();
     $field1->type = "textarea";
     $field1->name = "indredient2";
     $field1->title = "Indredient 2";
     $field1->description = "Dit is de omschrijving";
     $field1->validation = "required";
     $field1->value = "Bloem";
     $field2 = new StdClass();
     $field2->type = "hidden";
     $field2->name = "indredient3";
     $field2->title = "Indredient 3";
     $field2->description = "Dit is de omschrijving";
     $field2->validation = "required";
     $field2->value = "Kaneel";
     $data = array('indredient1' => $field, 'indredient2' => $field1, 'indredient3' => $field2);
     Post::create(["title" => "Appeltaart bakken", "content" => "Het meest eenvoudige appeltaart recept blijft het lekkerst. Dat gaat zeker op voor dit authentieke appeltaart recept van Koopmans. Met dit eenvoudige appeltaart recept maak je gemakkelijk deze Oudhollandse traktatie. Daar hoef je geen keukenprins of keukenprinses voor te zijn (maar dat mag natuurlijk wel). Volg het appeltaart recept op de achterkant en binnen twee uur heb je een heerlijke appeltaart op tafel staan. Ideaal als traktatie tijdens een verjaardagsfeestje voor jezelf of één van je kinderen, of gewoon zomaar, lekker bij de koffie. Met dit makkelijke appeltaart recept van Koopmans maak je iedereen blij. Jong én oud!", "url" => "appeltaart-bakken", "data" => "", "type" => "page"]);
     Post::create(["title" => "Lorem ipsum", "content" => "Lorem ipsum etc. etc.", "url" => "lorum-impsum", "data" => "", "type" => "page"]);
     Post::create(["title" => "Pagina van type Video", "content" => "Het meest eenvoudige appeltaart recept blijft het lekkerst. Dat gaat zeker op voor dit authentieke appeltaart recept van Koopmans. Met dit eenvoudige appeltaart recept maak je gemakkelijk deze Oudhollandse traktatie. Daar hoef je geen keukenprins of keukenprinses voor te zijn (maar dat mag natuurlijk wel). Volg het appeltaart recept op de achterkant en binnen twee uur heb je een heerlijke appeltaart op tafel staan. Ideaal als traktatie tijdens een verjaardagsfeestje voor jezelf of één van je kinderen, of gewoon zomaar, lekker bij de koffie. Met dit makkelijke appeltaart recept van Koopmans maak je iedereen blij. Jong én oud!", "url" => "appeltaart-bakken", "data" => "", "type" => "video"]);
     Post::create(["title" => "Post 1", "content" => "Lorem ipsum etc. etc.", "url" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "data" => "", "type" => "post"]);
     Post::create(["title" => "Post 2", "content" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "url" => "appeltaart-bakken", "data" => "", "type" => "post"]);
     Post::create(["title" => "Post 3", "content" => "Nullam pharetra imperdiet tempor. Aliquam erat volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed a dapibus augue. Donec suscipit lobortis dapibus. Nam felis tellus, finibus facilisis est ut, aliquet posuere urna. Quisque auctor quis magna ac vulputate. Etiam consequat nunc a leo elementum faucibus.", "url" => "lorum-impsum", "data" => "", "type" => "post"]);
 }
开发者ID:edgarravenhorst,项目名称:larabuild,代码行数:36,代码来源:PostTableSeader.php

示例7: store

 public function store(Request $request)
 {
     $post = Post::create(['title' => $request->title, 'slug' => $request->slug, 'content' => $request->content, 'image' => $request->image, 'author' => $request->author]);
     foreach ($request->categories as $category) {
         $post_category = PostCategory::create(['post_id' => $post->id, 'cat_id' => $category]);
     }
 }
开发者ID:BobbyHoltzner,项目名称:BH2016,代码行数:7,代码来源:PostController.php

示例8: store

 /**
  * Store a newly created Post
  *
  * @param PostCreateRequest $request
  */
 public function store(PostCreateRequest $request)
 {
     //dd($request->all());
     Post::create($request->postFillData());
     //$post->syncTags($request->get('tags', []));
     return redirect()->route('admin.post.index')->withSuccess('新文章创建完成.');
 }
开发者ID:boosb,项目名称:test,代码行数:12,代码来源:PostController.php

示例9: store

 public function store(PostRequest $request)
 {
     // dd($request->all());
     $post = Post::create($request->all());
     $post->tags()->attach($request->input('tag_list'));
     return redirect('dash/post')->with('message', 'Post was create success.');
 }
开发者ID:Yuth-Set,项目名称:cms,代码行数:7,代码来源:PostController.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(1, 10) as $number) {
         Post::create(['title' => '(db) post title ' . $number, 'content' => '(db) post content']);
     }
 }
开发者ID:shengyou,项目名称:laradiner-di-ioc-example,代码行数:12,代码来源:PostTableSeeder.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:3|max:100', 'description' => 'required|min:10', 'visible' => 'required']);
     $data = $request->all();
     if ($request->file) {
         $validate = ImageHelper::validate($request->file, 2000000);
         if (!$validate['success']) {
             return response()->json([$validate['message']], 422);
         }
     }
     if (isset($data['files'])) {
         $validate_multiple = ImageHelper::validateMultiple($data['files'], 20000000);
         if (!$validate_multiple['success']) {
             return response()->json([$validate_multiple['message']], 422);
         }
     }
     if ($request->file) {
         $image = ImageHelper::create($data['file'], 600, 'admin/images/posts/');
         $data['image'] = $image['filename'];
     }
     $post = Post::create($data);
     if (isset($data['files'])) {
         $image_multiple = ImageHelper::createMultiple($data['files'], 600, 'admin/images/posts/');
         for ($i = 0; $i < count($data['files']); $i++) {
             $post->PostImages()->save(new PostImages(['name' => $image_multiple['filenames'][$i]]));
         }
     }
     return response()->json(['message' => 'Post successfully Created']);
 }
开发者ID:subirrastogi,项目名称:laravel-angular-cms,代码行数:35,代码来源:PostController.php

示例12: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Post::create(['title' => $faker->sentence, 'body' => $faker->paragraph]);
     }
 }
开发者ID:xifat,项目名称:example-web-service-oauth2-laravel5,代码行数:7,代码来源:PostsTableSeeder.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $objects = factory(Post::class, 300)->make();
     foreach ($objects as $var) {
         Post::create($var->toArray());
     }
 }
开发者ID:guduchango,项目名称:laravelCommandBus,代码行数:12,代码来源:PostsTableSeeder.php

示例14: store

 /**
  * 存储文章到数据库
  *
  * @param PostCreateRequest $request
  */
 public function store(PostCreateRequest $request)
 {
     $post = Post::create($request->postFillData());
     $counts = Archive::where('name', '=', $request->archive)->first()->counts;
     $archive = Archive::where('name', '=', $request->archive)->update(['counts' => $counts + 1]);
     return redirect()->route('admin.post.index')->withSuccess('New Post Successfully Created.');
 }
开发者ID:Ruiming,项目名称:blog,代码行数:12,代码来源:PostController.php

示例15: run

 public function run()
 {
     DB::table('update_records')->delete();
     DB::table('view_cache')->delete();
     DB::table('posts')->delete();
     DB::table('threads')->delete();
     ##################
     Thread::create(['id' => 1, 'thread_id' => 111111111, 'board' => 'a', 'updated_num' => 0, 'views' => '500', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 111111111, 'thread_id' => 1, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111112, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111113, 'thread_id' => 1, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 111111114, 'thread_id' => 1, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 2, 'thread_id' => 222222222, 'board' => 'b', 'updated_num' => 0, 'views' => '555', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 222222222, 'thread_id' => 2, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222223, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222224, 'thread_id' => 2, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 222222225, 'thread_id' => 2, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 3, 'thread_id' => 333333333, 'board' => 'g', 'updated_num' => 3, 'views' => '123', 'notice' => 'Admin note: This thread is garbage.', 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null]);
     Post::create(['chan_id' => 333333333, 'thread_id' => 3, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333334, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333335, 'thread_id' => 3, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 333333336, 'thread_id' => 3, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     ##################
     Thread::create(['id' => 4, 'thread_id' => 444444444, 'board' => 'q', 'updated_num' => 10, 'views' => '1250', 'notice' => null, 'secret' => 'a719c9a1', 'takedown_reason' => null, 'tweeted_at' => null, 'deleted_at' => DB::raw('NOW()')]);
     Post::create(['chan_id' => 444444444, 'thread_id' => 4, 'original_image_name' => 'Imgur.jpg', 'image_size' => 128000, 'image_width' => '535', 'image_height' => '535', 'thumb_width' => '250', 'thumb_height' => '250', 'image_url' => 'http://i.imgur.com/UmmyTUG.png', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444445, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444446, 'thread_id' => 4, 'original_image_name' => 'Imgur 2.jpg', 'image_size' => 34000, 'image_width' => '500', 'image_height' => '466', 'thumb_width' => '116', 'thumb_height' => '125', 'image_url' => 'http://i.imgur.com/w6pQEvY.jpg', 'imgur_hash' => 'something', 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
     Post::create(['chan_id' => 444444447, 'thread_id' => 4, 'subject' => null, 'name' => 'Anonymous', 'tripcode' => null, 'capcode' => null, 'post_timestamp' => DB::raw('FROM_UNIXTIME(1429902005)'), 'body' => 'What is your movie editing software of choice? Pic related for me, but the things you can do it with are pretty limited. Is there a good (free) alternative for simple video editing?']);
 }
开发者ID:bibanon,项目名称:4archive,代码行数:31,代码来源:DatabaseSeeder.php


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