PHP code example of karlmonson / tenant

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

    

karlmonson / tenant example snippets


Karlmonson\Tenant\TenantServiceProvider::class,

'Tenant' => Karlmonson\Tenant\Facades\Tenant::class,



namespace App;

use Karlmonson\Tenant\Facades\Tenant;

class Store
{
    public function setKey($key, $value, $encrypt = false, $env = false)
    {
        Tenant::set($key, $value, $encrypt, $env);
    }
}



namespace App;

use Karlmonson\Tenant\Facades\Tenant;

class Store
{
    public function getKey($key, $default = null)
    {
        Tenant::get($key, $default);
    }
}



namespace App\Http\Controllers;

use App\Mail\TestMail;
use Illuminate\Support\Facades\Mail;
use Karlmonson\Tenant\Facades\Tenant;

class TestController extends Controller
{
    public function sendMail()
    {
        Tenant::swapConfig();
        
        Mail::to('[email protected]')->send(new TestMail());
    }
}

php artisan migrate

php artisan tenant:seed

php artisan tenant:get key

php artisan tenant:list