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


PHP Post::create方法代码示例

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


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

示例1: add

 function add()
 {
     if (!empty($this->data)) {
         $this->Post->create();
         if ($this->Post->save($this->data)) {
             $this->flash(__('Post saved.', true), array('action' => 'index'));
         } else {
         }
     }
 }
开发者ID:rafaelqueiroz,项目名称:mongoDB-Datasource,代码行数:10,代码来源:posts_controller.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::only('title', 'body');
     $validation = Validator::make($input, Post::$rules);
     if ($validation->passes()) {
         $this->post->create($input);
         return Redirect::route('posts.index');
     }
     return Redirect::route('posts.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
开发者ID:resulaslan,项目名称:sample-l4-app,代码行数:15,代码来源:PostsController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Post::$rules);
     if ($validation->passes()) {
         $this->post->create($input);
         return Response::json(array('success' => true, 'errors' => '', 'message' => 'Post created successfully.'));
     }
     return Response::json(array('success' => false, 'errors' => $validation, 'message' => 'All fields are required.'));
 }
开发者ID:sanabuck,项目名称:laravel-medium-editor,代码行数:15,代码来源:PostsController.php

示例4: run

 public function run()
 {
     DB::table('categories')->delete();
     Post::create(['category_name' => 'title']);
     Post::create(['category_name' => 'slug']);
     Post::create(['category_name' => 'excerpt']);
 }
开发者ID:Asekahud,项目名称:Web_Programming,代码行数:7,代码来源:DatabaseSeeder.php

示例5: post_create

 public function post_create()
 {
     $posts = Input::all();
     $title = $posts['thread_name'];
     $contentRaw = $posts['inputarea'];
     if ($title != '' && strlen($contentRaw) > 10) {
         $alias = Str::slug($title, '-');
         $exist = Thread::where('alias', '=', $alias)->first();
         if ($exist != null) {
             return Redirect::to($exist->id);
         }
         $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
         $thread = Thread::create($threadData);
         if ($thread != null) {
             $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
             $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
             $pst = Post::create($postData);
             if ($pst != null) {
                 return Redirect::to($thread->id);
             }
         }
     } else {
         return Redirect::to(URL::full());
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:25,代码来源:thread.php

示例6: testDelete

 public function testDelete()
 {
     $this->setExpectedException('AuthorizationRequired\\DeletePermissionException');
     $normal = Post::create(self::postData());
     $protected = ReadOnlyPost::find($normal->id);
     $protected->delete();
 }
开发者ID:orottier,项目名称:authorization-required,代码行数:7,代码来源:ReadOnlyTest.php

示例7: run

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

示例8: module_setup

	/**
	 * Sets up the fixture, for example, opens a network connection.
	 * This method is called before a test is executed.
	 *
	 * @access protected
	 */
	protected function module_setup()
	{
		$user = User::get_by_name( 'posts_test' );
		if ( !$user ) {
			$user = User::create( array (
				'username'=>'posts_test',
				'email'=>'posts_test@example.com',
				'password'=>md5('q' . rand( 0,65535 ) ),
			) );
		}
		$this->user = $user;
		$post = Post::create( array(
			'title' => 'Test Post',
			'content' => 'These tests expect there to be at least one post.',
			'user_id' => $user->id,
			'status' => Post::status( 'published' ),
			'content_type' => Post::type( 'entry' ),
		) );

		$this->post_id = $post->id;
		$this->paramarray = array(
			'id' => 'foofoo',
			'post_id' => $this->post_id,
			'name' => 'test',
			'email' => 'test@example.org',
			'url' => 'http://example.org',
			'ip' => ip2long('127.0.0.1'),
			'content' => 'test content',
			'status' => Comment::STATUS_UNAPPROVED,
			'date' => HabariDateTime::date_create(),
			'type' => Comment::COMMENT
		);
		$this->comment = Comment::create( $this->paramarray );
	}
开发者ID:rynodivino,项目名称:tests,代码行数:40,代码来源:test_comment.php

示例9: run

 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 25; $i++) {
         $user = Post::create(array('title' => $faker->sentence($nbwords = 5), 'slug' => $faker->slug, 'content' => $faker->text, 'excerpt' => $faker->sentence, 'image' => $faker->imageUrl($width = 640, $height = 480), 'post_category_id' => '1'));
     }
 }
开发者ID:arbuuuud,项目名称:gnt-aops,代码行数:7,代码来源:PostsTableSeeder.php

示例10: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Post::create(['title' => $faker->sentence(), 'body' => $faker->realText(500), 'user_id' => rand(1, 2)]);
     }
 }
开发者ID:hilmysyarif,项目名称:hotel-application-laravel,代码行数:7,代码来源:PostsTableSeeder.php

示例11: run

 public function run()
 {
     DB::table('posts')->delete();
     Post::create(array('title' => 'Mi primera noticia!', 'content' => 'Hola mundo desde el contenido de la noticia'));
     Post::create(array('title' => 'Mi segunda noticia!', 'content' => 'Contenido de la noticia'));
     Post::create(array('title' => 'ya esto paso a la tercera noticia!', 'content' => 'Contenido de la noticia 3'));
 }
开发者ID:jairoserrano,项目名称:SimpleBlogClase,代码行数:7,代码来源:PostTableSeeder.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = ['title' => $request->input('title'), 'author' => Auth::getName(), 'content_raw' => $request->input('editorValue'), 'content_html' => $request->input('editorValue'), 'published_at' => carbon::now()];
     Post::create($post);
     return redirect('/admin/post');
     //
 }
开发者ID:jwan3453,项目名称:glh,代码行数:13,代码来源:PostController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // get POST data
     $input = Input::all();
     // set validation rules
     $rules = array('title' => 'required', 'text' => 'required', 'image' => 'required');
     // validate input
     $validation = Validator::make($input, $rules);
     // if validation fails, return the user to the form w/ validation errors
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         // create new Post instance
         $post = Post::create(array('title' => $input['title']));
         // create Text instance w/ text body
         $text = Text::create(array('text' => $input['text']));
         // save new Text and associate w/ new post
         $post->text()->save($text);
         // create the new Image
         $image = Image::create(array('url' => $input['image']));
         // save new Text and associate w/ new post
         $post->image()->save($image);
         if (isset($input['tags'])) {
             foreach ($input['tags'] as $tagId) {
                 $tag = Tag::find($tagId);
                 $post->tags()->save($tag);
             }
         }
         // associate the post with the current user
         $post->author()->associate(Auth::user())->save();
         // redirect to newly created post page
         return Redirect::route('post.show', array($post->id));
     }
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:39,代码来源:PostController.php

示例14: run

 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     // DB::table('posts')->truncate();
     Post::create(['title' => 'test title', 'content' => 'something and more something']);
     // Uncomment the below to run the seeder
     // DB::table('posts')->insert($posts);
 }
开发者ID:DouglasDDo,项目名称:First-L4-Blog-App,代码行数:8,代码来源:PostsTableSeeder.php

示例15: run

 public function run()
 {
     DB::table('posts')->truncate();
     $faker = Factory::create();
     for ($i = 0; $i < 10; $i++) {
         Post::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(rand(3, 5)), 'user_id' => rand(1, 3)]);
     }
 }
开发者ID:ChoiceParalysis,项目名称:Larablog,代码行数:8,代码来源:PostsTableSeeder.php


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