1. Go to this page and download the library: Download fantismic/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/ */
fantismic / tenancy example snippets
use Fantismic\Tenancy\Facades\Tenancy;
$tenant = Tenancy::createTenant(
'Tenant Name', // Tenant display name
[ // Connection details for admin user
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'admin_db',
'username' => 'root',
'password' => 'secret',
],
[ // Options
'create_db' => true, // Create database & user (default: true)
'migrate' => true, // Run tenant migrations (default: true)
'seed' => null, // Seeder class to run (optional)
]
);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Fantismic\Tenancy\Traits\UsesTenantConnection;
class Invoice extends Model
{
use UsesTenantConnection;
// ...
}