steelants/laravel-tenant

Everything you need to start your Laravel journey.

2.0.9 2024-04-09 15:00 UTC

This package is auto-updated.

Last update: 2024-05-09 15:09:00 UTC


README

Currently WIP

Created by: SteelAnts s.r.o.

Total Downloads

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

Contributors

68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d737465656c616e74732f4c61726176656c2d426f696c6572706c617465

Other Packages

steelants/datatable

steelants/form

steelants/modal

Notes