Qore Tenant
This module adds Tenant functionality to your application. It can be added to any model of your choosing.
Installation
- Install the package via composer:
bash
composer require qore-works-business/qore-tenantbash
php artisan qore-tenant:install- Add the plugin to the plugins() section of the applications panel service provider:
php
use QoreWorksBusiness\QoreRelation\QoreTenantPlugin;
class QorePanelServiceProvider extends QorePanelServiceProviderBase
{
public function panel(QorePanel|Panel $panel): QorePanel
return parent::panel($panel)
// ....
->plugins([
QoreTenantPlugin::make(),
]);
}- Add the
Tenantablecontract andHasTenanttrait to your model.
php
use QoreWorksBusiness\QoreTenant\Concerns\HasTenant;
use QoreWorksBusiness\QoreTenant\Contracts\Tenantable;
class Company implements Tenantable
{
use HasTenant;
// ...- If you want to use the
TenantRelationManagerto manage Tenants from QWB, add theTenantRelationManagerto your filament resource.
php
use QoreWorksBusiness\QoreTenant\Resources\RelationManagers\TenantRelationManager;
public static function getRelations(): array
{
return [
// ...
TenantRelationManager::class,
];
}- If you want to use Tenant information in blade files you can use the
TenantComposerview composer in yourAppServiceProvider.
php
use QoreWorksBusiness\QoreTenant\View\Composers\TenantComposer;
public function boot(): void
{
view()->composer([
// any blade files
'application.portal.layouts.app',
'application.portal.layouts.guest',
], TenantComposer::class);
}- To route to the correct subdomain you can use the
TenantBySubdomainMiddlewaremiddleware. You can use this for most QWB applications (website, portal). Currently Statamic websites are not supported out of the box, but can work with Laravel subdomain routing.
php
//config/portal.php
use QoreWorksBusiness\QoreTenant\Http\Middleware\TenantBySubdomainMiddleware;
return [
'middleware' => [
'web',
TenantBySubdomainMiddleware::class,
],
// ...
];- Add your main domain to the
.env
MAIN_DOMAIN=