I have a strange situation happening in my project.
I two DB tables in my project. Say 'posts' and 'comments'. I have set up a relationship in my comment model saying:
public function post(){
return $this->belongsTo('App/Models/Post', 'post_id');
}
I have a situation where there are some comments in the DB where the post_id is NULL. Then there are some posts in the DB where the ID is primary key is null (don't ask) so what is happening is that a relationship is being formed between comments and posts which should not be formed due to the two of them happening to have NULL as a value.
Is there any way to fix that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire