User
public function customer()
{
return $this->hasOne(Customer::class);
}
Customer
public function user()
{
return $this->belongsTo(User::class);
}
public function detail()
{
return $this->hasOne(CustomersDetail::class);
}
public function images()
{
return $this->morphToMany(Image::class, 'imagable');
}
customers table has a user_id
CustomersDetail
public function customer()
{
return $this->belongsTo(Customer::class);
}
customers_detail table has a customer_id
Image
public function customer()
{
return $this->morphedByMany(Customer::class, 'imagable');
}
images has 2 tables: images: id, name, filename ? imagables image_id, imagable_type, imagable_id
$userData = User::with('customer.detail', 'customer.images')->find(1);
Will give you user 1, with it's customer object, it's details, and images.
For the DB : read https://laravel.com/docs/5.5/eloquent-relationships as well.