In your User model
public function data()
{
return $this->hasMany('UserData');
}
In your UserData model
public function user()
{
return $this->belongsTo('User');
}
You can then access your user data as such
$user->data // Eloquent collection of the data associated with the user
$user->data() // Query object you can query the user_data table
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community