Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ErikRobles's avatar

Looking for How to create Multi-School Authentication

I have been looking for information on how to create a multi-School Authentication system (similar to Multi-Vendor Auth) but am not really finding a lot of information on how to set it up. If anyone can suggest resources on this, I would be greatful. I want any school to be able to register and create their own list of teachers and students as well as other features. Thanks in advance.

0 likes
9 replies
jlrdw's avatar

You would have school id and user id.

So you would not only check the authenticated user you would make sure the correct School also.

1 like
ErikRobles's avatar

@webrobert Quick Question. On the last instruction in the docs, I am left confused as to me they are not very clear and I was hoping you could shed some light on this for me. I would sure appreciate it. It is in this section of the docs:

Now we'll create a user inside each tenant's database:
App\Models\Tenant::all()->runForEach(function () {
    App\Models\User::factory()->create();
});

I'm not sure where to place this code. Thanks in advance

webrobert's avatar
Level 51

@ErikRobles, the article? I believe he is running them via tinker...

 >> $tenant1 = Tenant::create(['id' => 'foo']);
 >> $tenant1->domains()->create(['domain' => 'foo.saas.test']);

 >> $tenant2 = Tenant::create(['id' => 'bar']);
 >> $tenant2->domains()->create(['domain' => 'bar.saas.test']);

 >> App\Tenant::all()->runForEach(function () {
   factory(App\User::class)->create();
 });

He's just demo'ing creating tenants.

ErikRobles's avatar

@webrobert Ahhh makes sense. Thank you. I missed the tripple arrow (double arrow in the example). Works like a charm.

Please or to participate in this conversation.