Multiple Customers Multiple Users - Separating Data through Eloquent

Posted 5 months ago by eleven0

Say I have a customer (a company) in England and this customer has 10 users using my app. Each user creates its own content, records etc. Resource is shared within that company based on that user's access level etc.

My question is what's the proper way to separate this company's data, information from a US customer's data all together?

So for instance, when user of the customer in England is trying to access information; I do if statements to check if user's customer id matches the data's customer id (to ensure user is able to access only his(or customer's) data.

  ``` if ($companyDirectory->customer_id == $usercustomerid) {
        $company = CompanyDirectory::all()->where('id', $companyid);```

I do this in my controllers. Is this a proper way to approach this or should I be doing something with model to make this separation between data from different unrelated users and customers?

What do you think?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.