The table name that is used to save the data in is based on your model. The foreign key however is based on the relationship. So in your example it works because both relationships have the default key model_id. If you would rename one of the keys it wouldn't work anymore.
return $this->hasMany('App\Post', 'post_user_id');
So basically this is just a coincidence and you should make sure to use the correct relationship. :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community