{"id":34007566,"url":"https://github.com/yanhao-li/office-building","last_synced_at":"2026-04-05T11:31:51.486Z","repository":{"id":57085972,"uuid":"125883791","full_name":"yanhao-li/office-building","owner":"yanhao-li","description":"🏢  Easy to use SaaS Multitenancy solution for Laravel","archived":false,"fork":false,"pushed_at":"2018-07-20T20:48:30.000Z","size":46,"stargazers_count":27,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-14T22:54:07.975Z","etag":null,"topics":["composer","laravel","multitenancy","multitenant","php","separate-database"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yanhao-li.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-19T15:57:02.000Z","updated_at":"2024-11-28T09:57:03.000Z","dependencies_parsed_at":"2022-08-25T00:50:29.584Z","dependency_job_id":null,"html_url":"https://github.com/yanhao-li/office-building","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/yanhao-li/office-building","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanhao-li%2Foffice-building","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanhao-li%2Foffice-building/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanhao-li%2Foffice-building/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanhao-li%2Foffice-building/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yanhao-li","download_url":"https://codeload.github.com/yanhao-li/office-building/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanhao-li%2Foffice-building/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31434624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","laravel","multitenancy","multitenant","php","separate-database"],"created_at":"2025-12-13T11:05:50.681Z","updated_at":"2026-04-05T11:31:51.440Z","avatar_url":"https://github.com/yanhao-li.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://yanhaoli.com/office-building/logo.svg\" /\u003e\n\u003c/p\u003e\n\n# Office Building\n[![Travis](https://img.shields.io/travis/yanhao-li/office-building.svg)](https://travis-ci.org/yanhao-li/office-building) ![license](https://img.shields.io/github/license/mashape/apistatus.svg) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md#pull-requests)\n\nOffice Building is an easy to use Laravel package to help you build the Multi-tenant SaaS with database-per-tenant.\nSupport Laravel 5.3+\n\n## Installation\n\nInstall Office Building via Composer:\n\n```bash\ncomposer require yanhaoli/office-building\n```\nFor laravel \u003e= 5.5 that's all, thanks to [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery).\n\nFor laravel \u003c= 5.5, you have to add `Yanhaoli\\OfficeBuilding\\Providers\\OfficeBuildingServiceProvider` to your `config/app.php` providers array:\n```php\nYanhaoli\\OfficeBuilding\\Providers\\OfficeBuildingServiceProvider::class,\n```\n\n\n## Usage\n\n1. Config the basis\n    Firstly you have to publish the config file with the following command:\n\n    ```php\n    php artisan vendor:publish --provider=\"Yanhaoli\\OfficeBuilding\\Providers\\OfficeBuildingServiceProvider\"\n    ```\n\n    Now checkout `config/officebuilding.php` and modify it by your needs.\n\n2. Open a new Office for your customer\n\n    ``` php\n    \u003c?php\n\n    namespace App\\Http\\Controller;\n    use OfficeBuilding;\n    use App\\Company;\n\n    class CompanyController extends Controller\n    {\n      public function create(Request $request)\n      {\n        $company_name = $request-\u003einput('name');\n        $database_name = OfficeBuilding::addOffice($company_name);\n        $company = new Company;\n        $company-\u003ename = $company_name;\n        $company-\u003edatabase_name = $database_name;\n        $company-\u003esave();\n        return response('created', 201);\n      }\n    }\n    ```\n\n3. Handle request for a specific office. Ex, Get all employees of that office\n\n    use OfficeBuilding::visit method to switch database connection to a specific office, with a callback method to handle request, the connection will be revert to the previous status after task completed.\n\n    ```php\n    \u003c?php\n\n    namespace App\\Http\\Controller;\n    use OfficeBuilding;\n    use App\\OfficeBuilding\\Employee;\n\n    class OfficeEmployeeController extends Controller\n    {\n      public function browse(Request $request, $office_id)\n      {\n        $employees = OfficeBuilding::visit($office_id, function(){\n          return Employee::all();\n        });\n\n        return response($employees, 200);\n      }\n    }\n    ```\n\n## Contributing\nWelcome any contributions for issue fix or functionality improvement.\n\n## Security Vulnerabilities\n\nIf you discover a security vulnerability , please shot me an email at hi@yanhaoli.com.\n\n## License\n\nThe MIT License (MIT). Please see [MIT license](http://opensource.org/licenses/MIT) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanhao-li%2Foffice-building","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanhao-li%2Foffice-building","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanhao-li%2Foffice-building/lists"}