PHP code example of takeshiyu / tenantify

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

    

takeshiyu / tenantify example snippets


return [
    'tenant_domain' => 'tenantify.test',
    'tenant_model' => App\Models\Tenant::class,
    'tenant_column' => 'slug',
    'tenant_key' => 'tenant_id',
];

use TakeshiYu\Tenantify\Concerns\Tenantable;

class YourTenantModel extends Model
{
    use Tenantable;
}

use TakeshiYu\Tenantify\Concerns\HasTenancy;

class YourModel extends Model
{
    use HasTenancy;
}

Route::tenancy(function () {
    // your tenant routes here ...
});

Route::get('/', fn () => 'ok')->middleware('tenantify.resolve');

use TakeshiYu\Tenantify\Tenancy;

Tenancy::tenant();  // returns current tenant instance
Tenancy::id();      // returns current tenant id
Tenancy::slug();    // returns current tenant slug
bash
php artisan vendor:publish --provider="TakeshiYu\Tenantify\TenantifyServiceProvider"