コード例 #1
0
 public function create()
 {
     redirect_guest_user(LOGIN_URL);
     $thread = Thread::get(Param::get('thread_id'));
     $page = Param::get('page_next');
     $auth_user = User::getAuthenticated();
     if (!$auth_user) {
         return;
     }
     if ($page == 'create_end') {
         $comment = new Comment();
         $comment->body = trim(Param::get('body'));
         $comment->user_id = $auth_user->id;
         try {
             $comment->create($thread);
             $follow = Follow::getByThreadAndUser($thread->id, $comment->user_id);
             if ($follow) {
                 $thread = Thread::get($thread->id);
                 $last_comment = Comment::getLastInThread($thread);
                 if ($last_comment) {
                     $follow->last_comment = $last_comment->id;
                     $follow->update();
                 }
             }
             redirect(VIEW_THREAD_URL, array('id' => $thread->id));
         } catch (ValidationException $e) {
             $page = 'create';
         }
     } else {
         throw new PageNotFoundException();
     }
     $title = 'Create Comment';
     $this->set(get_defined_vars());
     $this->render($page);
 }
コード例 #2
0
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(['user_id' => 1, 'entry_id' => 1, 'content' => "A retravailler niveau orthographe !"]);
     Comment::create(['user_id' => 2, 'entry_id' => 1, 'content' => "Nul !"]);
     Comment::create(['user_id' => 1, 'entry_id' => 2, 'content' => "Sympa :-)"]);
 }
コード例 #3
0
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(array('author' => 'Nathanael Smith', 'text' => 'Look this is a new test comment'));
     Comment::create(array('author' => 'D Barksdale', 'text' => 'No, the king stay the king'));
     Comment::create(array('author' => 'Detective Greggs', 'text' => 'If I hear the music I\'m gunna dance'));
 }
コード例 #4
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Comment::create([]);
     }
 }
コード例 #5
0
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(array('author' => 'Chris Sevilleja', 'text' => 'Look I am a test comment.'));
     Comment::create(array('author' => 'Nick Cerminara', 'text' => 'This is going to be super crazy.'));
     Comment::create(array('author' => 'Holly Lloyd', 'text' => 'I am a master of Laravel and Angular.'));
 }
コード例 #6
0
ファイル: test_comment.php プロジェクト: habari/tests
 public function test_delete_comment()
 {
     $comment = Comment::create($this->paramarray);
     $id = $comment->id;
     $comment->delete();
     $this->assert_false(Comment::get($id));
 }
コード例 #7
0
ファイル: CommentSeeder.php プロジェクト: jtaurus/jtauri_blog
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Comment::create(array('user_id' => 1, 'post_id' => 1, 'body_comment' => 'This is the body for a comment'));
     Comment::create(array('user_id' => 2, 'post_id' => 3, 'body_comment' => 'This is the body for a comment'));
     Comment::create(array('user_id' => 3, 'post_id' => 3, 'body_comment' => 'This is the body for a comment'));
 }
コード例 #8
0
 /**
  * Store a newly created resource in storage.
  * POST /comments
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $data['users_id'] = Auth::user()->id;
     Comment::create($data);
     return Redirect::back();
 }
コード例 #9
0
 protected function getOrCreateComment($wordpressID)
 {
     if ($wordpressID && ($comment = Comment::get()->filter(array('WordpressID' => $wordpressID))->first())) {
         return $comment;
     }
     return Comment::create();
 }
コード例 #10
0
 public function saveComment()
 {
     $comment = Comment::create(Input::all());
     $comment->user;
     $comment->qpon;
     $response = array("status" => "OK", "messages" => array("id" => 1, "message" => "Comment was saved succesfully..."), "comment" => $comment->toArray());
     return Response::json($response);
 }
コード例 #11
0
ファイル: Article.php プロジェクト: ralmarri12/mudwana
 public function add_comment($author_name, $content)
 {
     try {
         Comment::create($this->_id, $author_name, $content);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
コード例 #12
0
ファイル: CommentSeeder.php プロジェクト: return-zero/ma9
 public function run()
 {
     $comment = array('コメントやで', 'コメントだよ', 'コメントでおま', 'コマントなのです!', 'コメント5', 'コメント6', 'コメントやで', 'コメントだよ4', 'コメントでおま4', 'コマントなのです!2', 'コメントだよ2');
     $now = date('Y-m-d H:i:s');
     foreach ($comment as $c) {
         Comment::create(array('user_id' => mt_rand(1, 4), 'item_id' => mt_rand(1, 8), 'comment' => $c, 'created_at' => $now, 'updated_at' => $now));
     }
 }
コード例 #13
0
ファイル: HasManyTest.php プロジェクト: janmarek/Ormion
 public function testNewRecordWithNewReferenced()
 {
     $page = Page::create(array("name" => "English article", "description" => "Description", "text" => "Text in english.", "allowed" => true));
     $page->Comments[] = Comment::create(array("text" => "muj názor", "name" => "Honza", "mail" => "*****@*****.**"));
     $page->Comments[] = Comment::create(array("text" => "muj jiný názor", "name" => "Honza", "mail" => "*****@*****.**"));
     $page->save();
     $this->assertEquals(2, count(Page::findByName("English article")->Comments));
 }
コード例 #14
0
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 4));
     Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 3));
     Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 2));
     Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 1));
 }
コード例 #15
0
 /**
  * Create and store new comment.
  * 
  * @param  array $data
  * @return \FIIP\Comments\Comment|null
  */
 public function create(array $data)
 {
     $comment = Comment::create($data);
     if (!$comment->id) {
         return null;
     }
     return $this->find($comment->id);
 }
コード例 #16
0
 public function doSubmit($data, $form)
 {
     $comment = Comment::create();
     $form->saveInto($comment);
     $comment->PostID = $this->owner->ID;
     $comment->write();
     $this->owner->redirectBack();
 }
コード例 #17
0
 public function run()
 {
     $faker = Faker::create();
     Comment::truncate();
     $posts = Post::all();
     foreach (range(1, 50) as $index) {
         Comment::create(['user_id' => $faker->numberBetween($min = 1, $max = 10), 'post_id' => rand(1, $posts->count()), 'text' => $faker->paragraph($nbSentences = 3), 'attachment_id' => 0]);
     }
 }
コード例 #18
0
ファイル: blog.php プロジェクト: bakineggs/bakineggs.com
function create_comment($entry, $attributes)
{
    $recaptcha_response = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $attributes["recaptcha_challenge_field"], $attributes["recaptcha_response_field"]);
    if ($recaptcha_response->is_valid && Comment::create($entry, $attributes['body'], $attributes['author'], $_SERVER['REMOTE_ADDR'])) {
        render_entry($entry);
    } else {
        render_entry($entry, $attributes, $recaptcha_response->error);
    }
}
コード例 #19
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::lists('id');
     $posts = Post::lists('id');
     foreach (range(1, 100) as $index) {
         Comment::create(['body' => $faker->sentence(), 'user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts)]);
     }
 }
コード例 #20
0
 public function run()
 {
     $faker = Faker::create();
     // clear all data
     DB::table('comments')->truncate();
     foreach (range(1, 20) as $index) {
         Comment::create(['id' => $index, 'name' => 'DummyUser' . $index, 'email' => 'DummyUser' . $index . '@Dummy.com', 'content' => 'DummyContentDummyContent' . $index, 'post_id' => rand(1, 10), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     }
 }
コード例 #21
0
ファイル: Model.php プロジェクト: TheDenisNovikov/teacher
 public function comment($title, $content, User $user)
 {
     $key = camel2under(get_called_class());
     $info = compact('user', 'title', 'content');
     $info[$key] = $this;
     $c = Comment::create($info);
     $this->update(array('touched=NOW()' => null));
     return $c;
 }
コード例 #22
0
 /**
  * 填充评论数据
  * @return void
  */
 private function seedComment()
 {
     Comment::truncate();
     // 清空表
     for ($i = 1; $i < 30; $i++) {
         Comment::create(array('user_id' => $i, 'article_id' => 1 + $i % 5 + 28, 'content' => '评论内容' . $i));
         Article::find(1 + $i % 5 + 28)->increment('comments_count');
     }
     $this->command->info('随机评论数据填充完毕');
 }
コード例 #23
0
 /**
  * Store a newly created resource in storage.
  * @return Response
  */
 public function store()
 {
     $datas = Input::all();
     $validator = Validator::make($datas, Comment::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput()->with("error", "Oops Something Wrong");
     }
     Comment::create($datas);
     return Redirect::back()->with('success', 'Thanks for your comment');
 }
コード例 #24
0
ファイル: BlogPage.php プロジェクト: tcaiger/mSupplyNZ
 public function handleComment($data, $form)
 {
     $comment = Comment::create();
     $comment->Name = $data['Name'];
     $comment->Comment = $data['Comment'];
     $comment->ParentID = $this->ID;
     $comment->write();
     $form->sessionMessage('Thanks for your comment!', 'good');
     return $this->redirectBack();
 }
コード例 #25
0
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 1, 'user_id' => 1));
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 1, 'user_id' => 2));
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 2, 'user_id' => 1));
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 2, 'user_id' => 2));
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 3, 'user_id' => 1));
     Comment::create(array('text' => 'Great Post, Thanks!', 'post_id' => 3, 'user_id' => 2));
 }
コード例 #26
0
 public function add_comment()
 {
     if (!isset($_POST['comment']) || !isset($_POST['image_id'])) {
         return call('pages', 'error');
     }
     require_once 'models/comment.php';
     Comment::create($_POST['image_id'], $_POST['comment']);
     $_SESSION['notice'] = "Comments saved successfully";
     redirect_to('images', 'show/' . $_POST['image_id']);
 }
コード例 #27
0
 protected function tree($depth, $post_id, $parent_id, $time)
 {
     if (rand(0, 20) < $depth + 1) {
         return;
     }
     while (rand(0, 1) != 1) {
         $time = $time + rand(0, 100);
         $comment = Comment::create(['post_id' => $post_id, 'parent_id' => $parent_id, 'user_id' => rand(1, 100), 'created_at' => $time, 'updated_at' => $time, 'data' => $this->faker->paragraph, 'markdown' => '', 'upvotes' => 0, 'downvotes' => 0]);
         $this->tree($depth + 1, $post_id, $comment->id, $time + rand(0, 1000));
     }
 }
コード例 #28
0
 /**
  * Store a newly created comment in storage.
  *
  * @return Response
  */
 public function store($admin)
 {
     $validator = Validator::make($data = Input::all(), Comment::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Comment::create($data);
     $comment = Comment::whereUserName($admin)->first();
     dd($comment);
     return Redirect::route('admin.subjects.show', compact('admin', 'comment'));
 }
コード例 #29
0
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Comment::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['user_id'] = Auth::user()->id;
     $comment = Comment::create($data);
     $comment->post->increment('comments_count', 1);
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('posts.show', [$comment->post->id, '#comment-input']);
 }
コード例 #30
0
 public function post_add()
 {
     $id = Input::get('id');
     //Find the id of the post
     $post = Post::find($id);
     $validation = Comment::validate(Input::all());
     if ($validation->fails()) {
         return Redirect::to_route('post_view', $post->slug)->with_errors($validation)->with_input();
     } else {
         Comment::create(array('user' => Input::get('user'), 'post_id' => Input::get('id'), 'comment_msg' => Input::get('comment_msg')));
         return Redirect::to_route('post_view', $post->slug)->with('message', 'Comment Posted successfully!');
     }
 }