title: Create post with one category on eloquent laravel
body: <p>I want to create post with one category by user, my table</p>
  
  <pre><code>user
  id_user
  
  category
  id_category
  
  post
  id_post
  user_id
  category_id
  </code></pre>
  
  <p>This is my models</p>
  
  <pre><code>//User.php
  public function post()
  {
      return $this-&gt;hasMany('App\Post');
  }
  //Post.php
  public function user()
  {
      return $this-&gt;belongsTo('App\User');
  }
  //Category.php
  public function post()
  {
      return $this-&gt;hasMany('App\Post');
  }
  </code></pre>
  
  <p>and the <code>Request</code>:</p>
  
  <pre><code>//CreatePostRequest.php
  class CreatePostRequest extends Request {
  
  public function authorize()
  {
      return true;
  }
  public function rules()
  {
      return [
          'title' =&gt; 'required:min',
          'description' =&gt; 'required',
          'category_list' =&gt; 'required'
      ];
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have tried</p>
  
  <pre><code>$post= Auth::user()-&gt;post()-&gt;create($request-&gt;all());
  </code></pre>
  
  <p>But have error "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (<code>laravelproj</code>.<code>posts</code>, CONSTRAINT <code>posts_category_id_foreign</code> FOREIGN KEY (<code>category_id</code>) REFERENCES <code>categories</code> (<code>id_category</code>) ON DELETE CASCADE) (SQL: insert into <code>posts</code> (<code>title</code>, <code>description</code>, <code>user_id</code>, <code>updated_at</code>, <code>created_at</code>) values (Can buy somethingLorem ipsum dolor sit amet4, 2015-12-08 06:47:42, 2015-12-08 06:47:42, ?, ?))".
  How to solve this? Sorry for bad english</p>