You're looking at v1 documentation. The current version is v3. You can find the docs for the current version here.

Tenant Manager

This page documents a couple of other TenantManager methods you may find useful.

Finding tenant using UUID

find() is an alias for getTenantById(). You may use the second argument to specify the key(s) as a string/array.

>>> tenant()->find('dbe0b330-1a6e-11e9-b4c3-354da4b4f339');
=> [
     "uuid" => "dbe0b330-1a6e-11e9-b4c3-354da4b4f339",
     "domain" => "localhost",
     "foo" => "bar",
   ]
>>> tenant()->find('dbe0b330-1a6e-11e9-b4c3-354da4b4f339', 'foo');
=> [
     "foo" => "bar",
   ]
>>> tenant()->getTenantById('dbe0b330-1a6e-11e9-b4c3-354da4b4f339', ['foo', 'domain']);
=> [
     "foo" => "bar",
     "domain" => "localhost",
   ]

Getting tenant ID by domain

>>> tenant()->getTenantIdByDomain('localhost');
=> "b3ce3f90-1a88-11e9-a6b0-038c6337ae50"
>>> tenant()->getIdByDomain('localhost');
=> "b3ce3f90-1a88-11e9-a6b0-038c6337ae50"

Finding tenant by domain

You may use the second argument to specify the key(s) as a string/array.

>>> tenant()->findByDomain('localhost');
=> [
     "uuid" => "b3ce3f90-1a88-11e9-a6b0-038c6337ae50",
     "domain" => "localhost",
   ]

Accessing the array

You can access the public array tenant of TenantManager like this:

tenancy()->tenant

which is an array. If you want to get the value of a specific key from the array, you can use one of the helpers the key on the tenant array as an argument.

tenant('uuid'); // Does the same thing as tenant()->tenant['uuid']

Getting all tenants

This method returns a collection of arrays.

>>> tenant()->all();
=> Illuminate\Support\Collection {#2980
     all: [
       [
         "uuid" => "32e20780-1a88-11e9-a051-4b6489a7edac",
         "domain" => "localhost",
       ],
       [
         "uuid" => "49670df0-1a87-11e9-b7ba-cf5353777957",
         "domain" => "dev.localhost",
       ],
     ],
   }
>>> tenant()->all()->pluck('domain');
=> Illuminate\Support\Collection {#2983
     all: [
       "localhost",
       "dev.localhost",
     ],
   }

Deleting a tenant

>>> tenant()->delete('dbe0b330-1a6e-11e9-b4c3-354da4b4f339');
=> true
>>> tenant()->delete(tenant()->getTenantIdByDomain('dev.localhost'));
=> true
>>> tenant()->delete(tenant()->findByDomain('localhost')['uuid']);
=> true

This doesn't delete the tenant's database. If you want to delete it, save the database name prior to deleting the tenant. You can get the database name using getDatabaseName()

>>> tenant()->getDatabaseName(tenant()->findByDomain('laravel.localhost'))
=> "tenant67412a60-1c01-11e9-a9e9-f799baa56fd9"