archtechx / tenancy

Automatic multi-tenancy for Laravel. No code changes needed.
https://tenancyforlaravel.com
MIT License
3.67k stars 432 forks source link

Database manager for driver mariadb is not registered #1264

Closed Dechie closed 1 month ago

Dechie commented 1 month ago

Bug description

creating a record inside database doesn't work for mariadb because database manager driver for mariadb is not registered. Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException

Steps to reproduce

  1. start fresh laravel project:
  2. set db connection to mariadb in .env: DB_CONNECTION=mariadb
  3. install stancl/tenancy normally
  4. create custom tenant model `namespace App\Models;

use Stancl\Tenancy\Database\Models\Tenant as BaseTenant; use Stancl\Tenancy\Contracts\TenantWithDatabase; use Stancl\Tenancy\Database\Concerns\HasDatabase; use Stancl\Tenancy\Database\Concerns\HasDomains; use Stancl\Tenancy\DatabaseConfig; use Illuminate\Database\Eloquent\Model;

use Truck; use Driver; use Staff; use Warehouse;

class Company extends BaseTenant implements TenantWithDatabase { //

public function database() : DatabaseConfig 
{
    return new DatabaseConfig($this);    
}
public function drivers() {
    return $this->hasMany(Driver::class);
}

public function staff() {
    return $this->hasMany(Staff::class);
}

public function warehouses() {
    return $this->hasMany(Warehouse::class);
}

public function trucks(){
    return $this->hasMany(Truck::class);
} 

}`

  1. use tinker tool to instantiate an object of the custom tenant model $company1 = App\Models\Company::create(['id' => 0, 'name' => 'my_company', 'special_code' => 'foode']); cccc

Expected behavior

An Object of The Custom Tenant model is successfully instantiated and inserted into database.

Laravel version

11.28.0

stancl/tenancy version

3.8

stancl commented 1 month ago

Try using the MySQL DB manager for 'mariadb' in the tenancy config.