PHP code example of steelants / laravel-tenant

1. Go to this page and download the library: Download steelants/laravel-tenant library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

steelants / laravel-tenant example snippets


// Access tenant manager
tenantManager()

// Access current tenant object
tenant()

// is helper wrapper function for
app(TenantManager::class)->getTenant();

// 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(...);

// Find your tenant
$tenant = Tenant::find($tenantId);

// Set as current tenant
tenantManager()->set($tenant);

php artisan vendor:publish --tag=tenant-migrations
php artisan migrate
json
{
    ...
    "autoload": {
        ...
        "files": [
            "app/helpers.php"
        ]
    },
    ...
}