Skip to content

Commit

Permalink
add tennant examble
Browse files Browse the repository at this point in the history
  • Loading branch information
alegerber committed Mar 18, 2024
1 parent 2725a35 commit de80c57
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions example/CatalogsTenantModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Models\Tenant;

use Spatie\Multitenancy\Models\Tenant;
use Mariadb\CatalogsPHP\Catalog;
/**
* Class CatalogsTenantModel
* @package App\Models\Tenant
* @description Example of a tenant model used in a multi-tenancy application with MariaDB Catalogs
*/
class CatalogsTenantModel extends Tenant
{
private static $catalog;

protected static function booted()
{
static::creating(fn(CatalogsTenantModel $model) => $model->createCatalogs());
}

public function createCatalogs()
{
if (self::$catalog === null) {
self::$catalog = new Catalog('localhost', 3306, 'root', 'rootPassword');
}

self::$catalog->create('test01');
}
}

0 comments on commit de80c57

Please sign in to comment.