An application for multiple customers with Laravel

Asked

Viewed 820 times

2

I’m creating a multi-client web application project using Laravel. In my project this application would have several databases, one for each customer. Searching the internet, I saw that with the passage of time it would be difficult to maintain, for several questions like: maintenance, backups and etc... considering it would be better to create an application with unique database and relating these tables? Our biggest fear is to have a mix of this data in the application. Someone could give us a light...?

2 answers

4

For your solution you could research on multi-tenancy architecture.

I’ve been looking over multi-tenancy in Laravel and unfortunately I haven’t found much (pre-ready).

Basically you create a Tenancy table (tenants or user, for example) and in ALL tables you fix who is the owner of that data.

In every query you will have to add the tenant_id of the logged in user.

I didn’t find any interesting link in stack overflow in English, so I’ll leave this iMasters link for you http://imasters.com.br/artigo/19067/cloud/entendendo-o-modelo-multi-tenancy/.

@Edit the model you are looking for is called Saas (Software as a Service).

  • Thanks For replying Willian, I’m searching the nominee.

  • People from the negative and do not comment kkkkk, too funny.

3


If you’re going to keep the same tables for customers, or the same basis, there’s no point in doing it. Just make a 1-to-1 relationship in each table with a user table that the data would not mix (it is the database’s premise not to allow this, but of course it needs the programmer’s collaboration), since each data belongs to a single client.

Gives a studied in relationship 1 to 1 in the databases such as Laravel works with them through the following link: http://laravel.com/docs/5.1/eloquent-relationships#one-to-one

[Edit] I had not read the other answer when I started this, but it is exactly what he says, one answer complements the other. ;)

  • True Gabriel Tadra. I’m researching here. Thank you!

  • Please choose an answer as sure! Thank you! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.