function add()
 {
     if (!empty($this->data)) {
         $this->Post->create();
         if ($this->Post->save($this->data)) {
             $this->flash(__('Post saved.', true), array('action' => 'index'));
         } else {
         }
     }
 }
 /**
  * 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.');
 }
 /**
  * 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.'));
 }
 public function run()
 {
     DB::table('categories')->delete();
     Post::create(['category_name' => 'title']);
     Post::create(['category_name' => 'slug']);
     Post::create(['category_name' => 'excerpt']);
 }
Example #5
0
 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());
     }
 }
 public function testDelete()
 {
     $this->setExpectedException('AuthorizationRequired\\DeletePermissionException');
     $normal = Post::create(self::postData());
     $protected = ReadOnlyPost::find($normal->id);
     $protected->delete();
 }
Example #7
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Post::create([]);
     }
 }
Example #8
0
	/**
	 * 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'=>'*****@*****.**',
				'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' => '*****@*****.**',
			'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 );
	}
Example #9
0
 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'));
     }
 }
 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)]);
     }
 }
 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'));
 }
Example #12
0
 /**
  * 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');
     //
 }
 /**
  * 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));
     }
 }
 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);
 }
 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)]);
     }
 }
 public function run()
 {
     DB::table('posts')->delete();
     $user_id = User::first()->id;
     Post::create(array('user_id' => $user_id, 'title' => 'Lorem ipsum dolor sit amet', 'slug' => 'lorem-ipsum-dolor-sit-amet', 'content' => $this->content, 'meta_title' => 'meta_title1', 'meta_description' => 'meta_description1', 'meta_keywords' => 'meta_keywords1', 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
     Post::create(array('user_id' => $user_id, 'title' => 'Vivendo suscipiantur vim te vix', 'slug' => 'vivendo-suscipiantur-vim-te-vix', 'content' => $this->content, 'meta_title' => 'meta_title2', 'meta_description' => 'meta_description2', 'meta_keywords' => 'meta_keywords2', 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
     Post::create(array('user_id' => $user_id, 'title' => 'In iisque similique reprimique eum', 'slug' => 'in-iisque-similique-reprimique-eum', 'content' => $this->content, 'meta_title' => 'meta_title3', 'meta_description' => 'meta_description3', 'meta_keywords' => 'meta_keywords3', 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
 }
Example #17
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Post::create(array('user_id' => 1, 'category_id' => 1, 'title' => 'This is a title', 'body' => 'This is a body', 'moderated' => true));
     Post::create(array('user_id' => 2, 'category_id' => 2, 'title' => 'This is the second title', 'body' => 'This is the second body', 'moderated' => true));
     Post::create(array('user_id' => 3, 'category_id' => 3, 'title' => 'This is the third title', 'body' => 'This is the third body', 'moderated' => true));
     Post::create(array('user_id' => 3, 'category_id' => 2, 'title' => 'This is the fourth title', 'body' => 'This article should no be visible by default because its moderated field is set to false', 'moderated' => false));
 }
 public function run()
 {
     DB::table('posts')->delete();
     Post::unguard();
     Post::create(['id' => 1, 'title' => 'First post', 'body' => 'This is the first post!']);
     Post::create(['id' => 2, 'title' => 'Second post', 'body' => 'This is the second post!']);
     Post::reguard();
 }
Example #19
0
 public function run()
 {
     $faker = Faker::create();
     Post::truncate();
     foreach (range(1, 20) as $index) {
         Post::create(['title' => $faker->sentence(5), 'content' => $faker->text(400)]);
     }
 }
 public function create()
 {
     $tags = $this->inputs->tags;
     unset($this->inputs->tags);
     Post::create($this->inputs);
     $response = Post::findLast();
     Helper::dd($response);
     REST::returnJson(['status' => 'ok']);
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     Post::truncate();
     foreach (range(1, 30) as $index) {
         $userId = User::orderBy(DB::raw('RAND()'))->first()->id;
         Post::create(['user_id' => $userId, 'title' => $faker->sentence(5), 'body' => $faker->paragraph(3)]);
     }
 }
 public function run()
 {
     $faker = Faker::create();
     $users = User::lists('id');
     $categories = Category::lists('id');
     foreach (range(1, 100) as $index) {
         Post::create(['title' => $faker->sentence(), 'slug' => $faker->slug() . $index, 'body' => $faker->text(), 'body_original' => $faker->text(), 'user_id' => $faker->randomElement($users), 'category_id' => $faker->randomElement($categories), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     }
 }
Example #23
0
 public function run()
 {
     //removes existing posts from table
     DB::table('posts')->delete();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Post::create(['title' => $faker->paragraph(1), 'content' => $faker->paragraph(40), 'status' => 'published', 'user_id' => $faker->numberBetween(1, 4)]);
     }
 }
 public function run()
 {
     DB::table('posts')->delete();
     Post::create(array('id' => 1, 'title' => 'Post About HTML/CSS', 'author_id' => 1, 'category_id' => 1));
     Post::create(array('id' => 2, 'title' => 'Post About PHP', 'author_id' => 2, 'category_id' => 2));
     Post::create(array('id' => 3, 'title' => 'Post About PHP/MySQL', 'author_id' => 1, 'category_id' => 3));
     Post::create(array('id' => 4, 'title' => 'Post About MongoDB', 'author_id' => 2, 'category_id' => 1));
     Post::create(array('id' => 5, 'title' => 'Post About jQuery', 'author_id' => 1, 'category_id' => 2));
 }
 public function run()
 {
     $faker = Faker::create();
     // clear all data
     DB::table('posts')->truncate();
     foreach (range(1, 10) as $index) {
         Post::create(['title' => 'Dummy Post # ' . $index, 'content' => 'Something dummy', 'category_id' => rand(1, 4), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     }
 }
Example #26
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         $time = time() - rand(0, 60 * 60 * 24 * 30);
         $type = rand(0, 1) == 0;
         Post::create(['section_id' => rand(2, 10), 'user_id' => rand(1, 10), 'created_at' => $time, 'updated_at' => $time, 'url' => $type ? '' : $faker->url, 'title' => $faker->sentence, 'data' => rand(0, 1) == 0 ? $faker->paragraph : '', 'markdown' => '', 'type' => $type, 'upvotes' => 0, 'downvotes' => 0, 'comment_count' => 0, 'thumbnail' => '', 'nsfw' => 0, 'nsfl' => 0]);
     }
 }
Example #27
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $title = $faker->sentence();
         $slug = str_replace(' ', '-', $title);
         Post::create(['title' => $title, 'slug' => $slug, 'body' => $faker->realText(1000), 'category_id' => rand(1, 3), 'tags' => str_replace(' ', '-', $faker->sentence(3)), 'icon' => 'default', 'user_id' => rand(1, 5)]);
     }
 }
 /**
  * Store a newly created post in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Post::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Post::create($data);
     return Redirect::route('admin.posts.index');
 }
 public function run()
 {
     Post::truncate();
     Post::create(['title' => 'Test Post', 'description' => 'This is a test post', 'url' => 'http://www.youtube.com', 'user_id' => '1', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 2', 'description' => 'This is a test post 2', 'url' => 'http://www.youtube.com', 'user_id' => '1', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
 }
Example #30
0
 public function action_create()
 {
     $slug = $this->slugger(Input::get('title'));
     $db = Post::create(array('post_title' => Input::get('title'), 'post_content' => Input::get('content'), 'slug' => $slug, 'user_id' => Auth::user()->id));
     if (!$db) {
         Log::write('admin.posts.create', 'Post was not created, post->create() returned false.');
         return Redirect::to('/admin/posts/new')->with('error_create', 'Unable to create post!');
     }
     return Redirect::to('/admin/posts/new')->with('status_create', 'New Post Created')->with('id', $db->id);
 }