orchestral / tenanti

[Package] Multi-tenant Database Schema Manager for Laravel
MIT License
587 stars 53 forks source link

[Job] How to use with the running job?? #72

Closed zmap95 closed 3 years ago

zmap95 commented 4 years ago

Currently, I got the prefix of the table from data of user logged in and after login I save prefix to the session. For example, cars belong to a building so the table in my database like building_1_cars So I got the problem when am I using the job, how I can use it with model when run a job? (because job don't have session).

crynobone commented 4 years ago

For example, cars belong to a building so the table in my database like building_1_cars So I got the problem when am I using the job, how I can use it with model when run a job? (because job don't have session).

While this is not handled directly by the package I'm failing to see how session going to give an impact here since you're still under the same database connection. I would guess (giving little information available here), you can either specifically set the Building model, and fetch Car for that model within the job?

zmap95 commented 4 years ago

In my case: I management many buildings and same 1 domain,

When I want to make the report cars per building end of day I using schedule to auto-generate but I don't know how to get it. Follow by my idea in my schedule file foreach ($buildings as $building) { $cars = Car::get(); // How to get the car from building ?? // For example: get all cars in the database building_1_cars }