title: I want to do comments system with Eloquent Polymorphic Relations?
body: <p>hi i want to build comments system in my projectDetail components 
  but an error show when i try to store the comment in DB[ 1048 Column 'commentable_id' cannot be null ]
  this is my ProjectDeatil.vue script :</p>
  
  <pre><code>  &lt;script&gt;
    export default {
        data(){
       return{
       key: this.$route.params.id,
  projets:[],
  projet:{
   id:'',
   name:'',
   durre:'',
   description:'',
   budget:'',
   owner:'',
     },
     membres:[],
      membre:{
      id :'',
      membre:'',
      projet_id:'',
  },
   form : new Form({
              id:'',
              body:''
  
              })
  
       }
  
  
  },
  
   methods:{
   afficherProjets(){
   axios.get('/api/getProjects')
    .then(({data}) =&gt; {this.projets=data.data});
   },
   afficherMembre(){
   axios.get('/api/membreid').then(({data})=&gt; {this.membres =data.data});
   },
    ajouterCommentaire(){
    this.form.post('/api/comments/'+this.key).then(()=&gt;{
    this.form.reset()})
    }
  
    },
    mounted() {
    console.log('Component mounted.')
    this.afficherProjets();
    this.afficherMembre();
  
    }
  
    }
  
  
   &lt;/script&gt;
  </code></pre>
  
  <p>and this my CommentController function:</p>
  
  <pre><code>public function store($key){
       //$data =$request-&gt;all();
      $projet=new  Projet;
       $commentaire =new Commentaire;
       $commentaire-&gt;user_id= auth()-&gt;user()-&gt;id;
       $commentaire-&gt;body= request('body');
       $commentaire-&gt;commentable_id = $key;
      $projet-&gt;comments()-&gt;save($commentaire);
  
  
  }
  </code></pre>
  
  <p>and this is my function in Model Comment:</p>
  
  <pre><code> public function commentable(){
         return $this-&gt;morphTo();
  }
  </code></pre>
  
  <p>and this my function  in Model Project:</p>
  
  <pre><code>public function comments(){
      return $this-&gt;morphMany('App\Commentaire','commentable')-&gt;latest();
  }
  </code></pre>
  
  <p>and this is this my route:</p>
  
  <pre><code> Route::post('/comments/{key}', 'API\CommentController@store');
  </code></pre>