Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steelants/laravel-tenant
https://github.com/steelants/laravel-tenant
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/steelants/laravel-tenant
- Owner: steelants
- License: mit
- Created: 2023-11-15T07:56:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-23T15:23:21.000Z (5 months ago)
- Last Synced: 2024-10-29T00:56:37.320Z (about 2 months ago)
- Language: PHP
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel-Tenant
## Currently WIP
### Created by: [SteelAnts s.r.o.](https://www.steelants.cz/)
[![Total Downloads](https://img.shields.io/packagist/dt/steelants/form.svg?style=flat-square)](https://packagist.org/packages/steelants/laravel-tenant)
### 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
```php
// Access tenant manager
tenantManager()// Access current tenant object
tenant()// is helper wrapper function for
app(TenantManager::class)->getTenant();
```### Sending emails
```php
// 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.
```php
// Find your tenant
$tenant = Tenant::find($tenantId);// Set as current tenant
tenantManager()->set($tenant);
```## Development
### Creation of symlinks for dev environment:
```bash
ln -s ./package/boilerplate/stubs/resources/ resources
```## Other Packages
[steelants/datatable](https://github.com/steelants/Livewire-DataTable)[steelants/form](https://github.com/steelants/Laravel-Form)
[steelants/modal](https://github.com/steelants/Livewire-Modal)
## Notes
* [Laravel MFA](https://dev.to/roxie/how-to-add-google-s-two-factor-authentication-to-a-laravel-8-application-4jjp)