steelants / laravel-tenant
Everything you need to start your Laravel journey.
Installs: 865
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/steelants/laravel-tenant
Requires
- laravel/framework: ^11.0|^12.0
Requires (Dev)
- barryvdh/laravel-debugbar: ^3.9
- phpunit/phpunit: ^11.0.1
- slevomat/coding-standard: ^8.19
- squizlabs/php_codesniffer: ^4.0
README
Currently WIP
Created by: SteelAnts s.r.o.
Install
php artisan vendor:publish --tag=tenant-migrations
php artisan migrate
If your tenants have thier own SMTP settings, add following into mailers
array in config/mail.php
'smtp_tenant' => [
'transport' => 'smtp',
'host' => '',
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => '',
'password' => '',
'timeout' => null,
'auth_mode' => null,
],
Usage
// Access tenant manager tenantManager() // Access current tenant object tenant() // is helper wrapper function for app(TenantManager::class)->getTenant();
Sending emails
// sending emial from tenants own SMTP server tenantManager()->mailer()->to(...)->send(...); // for sending emails from app's SMTP server use Laravel's default Mail class Mail::to(...)->send(...);
Running in console
By default, on web, tenant is set in TenantServiceProvider
by subdomain. To use tenant()
or tenantManager()->mailer()
in console,
for example in jobs, cron, ... you need to manualy set current tenant.
// Find your tenant $tenant = Tenant::find($tenantId); // Set as current tenant tenantManager()->set($tenant);
Development
Creation of symlinks for dev environment:
ln -s ./package/boilerplate/stubs/resources/ resources