A
A
Andr Lw12014-08-08 18:35:41
Laravel
Andr Lw1, 2014-08-08 18:35:41

How to create add comments to a post in Laravel4?

How to create add comments to a post in Laravel4?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andr Lw1, 2014-08-08
@lw1

Decision.
in routes.php :

Route::post('addcomment/{id}', array(
        'as' => 'comment',
        'uses' => '[email protected]'
    ));

in %filename%.blade.php :
{{ Form::model($post, array('action' => array('[email protected]', $post['id']))) }}
// Ваши данные
{{ Form::close() }}

in CommentController.php :
public function add($id){

      $data = Input::all();
      $new = $id;
      $data['post_id'] = $new;
      $comment = Comment::add($data);
}

and finally, in Comment.php :
$comment = Comment::create([

          //ваши данные
          //и id:
          'post_id' => $data['post_id']

        ]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question