PHP code example of tomatophp / filament-tenancy

1. Go to this page and download the library: Download tomatophp/filament-tenancy 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/ */

    

tomatophp / filament-tenancy example snippets


use Tomatophp\FilamentTenancy\FilamentTenancyPlugin;

->plugin(FilamentTenancyPlugin::make()->panel('app'))



use TomatoPHP\FilamentTenancy\FilamentTenancyAppPlugin;

->plugin(FilamentTenancyAppPlugin::make())

    ...
    'connections' => [
        'dynamic' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
        ...
    ],  

php artisan config:cache

use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain;

->withMiddleware(function (Middleware $middleware) {
    $middleware->group('universal', [
        InitializeTenancyByDomain::class,
        InitializeTenancyBySubdomain::class,
    ]);
})


use TomatoPHP\FilamentTenancy\FilamentTenancyPlugin;

->plugin(
    FilamentTenancyPlugin::make()
        ->panel('app')
        ->allowImpersonate()
)
bash
php artisan filament-tenancy:install
bash
php artisan filament:panel
bash
php artisan vendor:publish --tag="filament-tenancy-config"
bash
php artisan vendor:publish --tag="filament-tenancy-views"
bash
php artisan vendor:publish --tag="filament-tenancy-lang"
bash
php artisan vendor:publish --tag="filament-tenancy-migrations"