stancl / tenancy-docs

stancl/tenancy docs & website
https://tenancyforlaravel.com/docs
MIT License
64 stars 626 forks source link

tenancy 3.7 + Laravel/Breeze 1.21. #256

Closed devmikromike closed 1 year ago

devmikromike commented 1 year ago

Hello

I have tried to build login when using Breeze and tenant.

public function store(LoginRequest $request)
{
    $tenantID = $request->tenant_uuid;
    $tenant = Tenant::find($tenantID);
    tenancy()->initialize($tenant);    

    $tenantsUserCount = $tenant->run(function ($tenant) {
        return User::all();
    });
    dd($tenantsUserCount, $tenant);

I can read tenant database by $tenant->run(function) -callback

problem is how to swicht it and use it for $request->authenticate(); ???

    $request->authenticate();
    $request->session()->regenerate();
 }

if (Auth::check()) {
        dd('Auth check succefully!');
        return redirect('http://'.$domain.':8000'.'/dashboard');
    }

    return back()->withErrors([
        'email' => 'The provided credentials do not match our records.',
    ])->onlyInput('email');

it always return central DB and get's Error: 'The provided credentials do not match our records.'

Thanks Mika.

stancl commented 1 year ago

Please use our Discord server for support questions.