當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。