Relationship between USER and CUSTOMER

Hi All, Need some help.

We have installed and working on UserFrosting. In this we have 2 tables one for USER and another for CUSTOMER. So the thing that we want to acheive, want to provide a option from which we can assign a customer in USER.

For this we have created 3rd table where we want to make relationship between USER and CUSTOMER.

The issue is, we want to save Customer id in the 3rd table with User’s id. So basically in 3rd table we will show userd id and associated customer’s id.

So please suggest.

Did you try following the tutorial, Extending the User Model?

1 Like

There is also an example of how you can use global scopes to automatically join these tables together. See Extending API with MemberUser example

I’ll try to update the official docs soon.

Ok, the example extend-user Sprinkle has been updated, along with the documentation. Check it out!

So I’ve followed the tutorial examples of Extending the User Model as closely as possible (my extended Model name is Member and thus a table of ‘members’), and it all seems to work as far as seeing what’s happening in the database and being able to log in to the landing page. However, as soon as you try to do anything with tables that have corresponding ‘user_id’ columns, e.g. /users/u/ which tries to look up roles associated with the username, something goes FUBAR and the under the hood queries gets built with trying to use a non existing column id of ‘member_id’ instead of ‘user_id’. It’s like somewhere in that huge call stack, something is saying “use the name of the UserInterface autowire class + _id” instead of user_id. I’ve poked at the code and laravel docs for days and can’t for the life of me figure out where it’s happening to correct… any ideas? This is in UF 5.0 so maybe something is different than in 4.x

I’m in the same situation described by @sampenguin: my whole application was built with UF 4.0 and all the User stuff (that I previously extended with another model called Utente) was perfectly working until I decided to move on UF 5.0. I tried updating my code following the updated documentation on UF website, but everything related to the User Model is not working… :frowning: are we missing some parameters in our classes? Anyone can help us? Thanks!

@vertigofactory I just moved to Ruby on Rails, never having used it before (and having used UF 4.x for 6 months on a previous job). In 3 days I have significantly more working in RoR than I did in a week in UF 5. Does just about everything easier and faster and you can customize user account needs significantly easier.