title: Laravel relationships category and posts
body: <p>Occurred  a problem for adding relationships categories and posts. In the database there is three tables: categories(category_id, title), posts(post_id, text,title), category_post(category_id, post_id).
  Need to adding table category_post, but not adding. This is model category and post as well as their relationships.</p>
  
  <pre><code>    class Category extends Eloquent{
      protected $table = 'categories';
      protected $primaryKey = 'category_id';
  
      public function posts()
      {
          return $this-&gt;hasMany('Post');
      }
  }
  class Post extends Eloquent
  {
      protected $table = 'post';
      protected $primaryKey = 'post_id';
  
      public function category()
      {
          return $this-&gt;belongsTo('Category');
      }
  
      //Method add post. Called in the controller
      public static function add($data)
      {
          try {
              $post = new Post;
              $post-&gt;title = $data['title'];
              $post-&gt;text = $data['text'];
  
              $category = Category::find(1);
              $category-&gt;posts()-&gt;save($post);
          }catch (Exception $e){
              return $e;
          }
  
          return $category;
      }
  }
  </code></pre>
  
  <p>Return Exception. Help me please.</p>