tenancy-docs/docs/source/v2/central-app.blade.md
Samuel Štancl 33943b6a0e h2 -> h3
2019-10-12 22:06:05 +02:00

1.8 KiB

title description extends section
Central App Central App _layouts.documentation content

Central App

This package uses routes to separate the tenant part of the application from the central part of the application. The central part will commonly include a landing page, sign up form, and some sort of dashboard.

Central routes

Routes in the routes/web.php file are the central routes. When they are visited, tenancy is not intialized and any model, cache call, controller, job dispatch, Redis call and anything else that is called in during this request will be central.

Central domains

However, since you don't want routes related to the app on your main domain and sign up forms on tenant domains, you must also define what domains host the central stuff in the tenancy.exempt_domains config.

Using central things inside the tenant app

To use central things (databases/caches/Redis connections/filesystems/...) on special places of your tenant app, you may do the following.

Central database

Create a new connection and use it like DB::connection($connectionName)->table('foo')->where(...)

If you want to use models, create a getConnectionName() method that returns the name of the central connection

Central redis

Create a new connection, don't put it into tenancy.redis.prefixed_connections, and use it like Redis::connection('foo')->get('bar')

Central cache

Use the GlobalCache facade, or the global_cache() helper.

Central storage

Create a disk and don't add it to tenancy.filesystem.disks.

Central assets

Use the global_asset() helper.

Central queues

Coming soon.