Support the ongoing development of Laravel.io →
Database Eloquent Architecture
Last updated 2 years ago.
0

Is this a correct way to achieve this? What is the simplest to do this? Do you know any kind of resources/packages/libraries for this?

You could look into <github.com/orchestral/tenanti> to handle migrations/schema for tenants.

As for model, I would most likely use

<?php

class Customer extends Eloquent {
    public function getTable()
    {
        return Session::get('tenant.id').'_customers';
    }
}

What if there is a scenario that admin needs to view all the customers(or sales) in the entire database? How can I read from all the tables?

Could consider a daily/hourly cron to fetch records for denormalization for reporting purpose. Otherwise it could be a costly process and might affect app performance.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.