Comments (10)
Hi @dambridge, it's logic dependent.
If you have a separated users logic tenant by tenant, I can suggest to call php artisan tenants:artisan "passport:install"
.
If your users logic is included in your landlord, it isn't needed.
from laravel-multitenancy.
Change it:
exec('cd ' . base_path() . ' && php artisan tenants:artisan "migrate --seed" --tenant=' . $tenant->id);
with:
exec('cd ' . base_path() . ' && php artisan tenants:artisan "migrate --seed --connection=tenant" --tenant=' . $tenant->id);
It's really important to specify the connection.
from laravel-multitenancy.
@masterix21 In my registration handler, I'm basically going to do this then:
exec('cd ' . base_path() . ' && php artisan tenants:artisan "migrate --seed" --tenant=' . $tenant->id);
exec('cd ' . base_path() . ' && php artisan tenants:artisan "passport:install" --tenant=' . $tenant->id);
from laravel-multitenancy.
Yes, it seems ok What are your concerns?
PS: why don't you use: Artisan::call('tenants:artisan', [ "artisanCommand" => "passport:install", "--tenant" => $tenant->id ]);
?
from laravel-multitenancy.
Per #23 , there are issues I had running Artisan directly.
Also, I just tried it but the Passport tables were still installed in the landlord database.
from laravel-multitenancy.
Have you moved the passport migrations inside the tenant directory?
from laravel-multitenancy.
Yes. Well, the default migrations folder is the tenant directory, so that's where they are. Must be using the wrong connection somehow, but the other migrate command runs just fine. My Task:
<?php
namespace App\Tasks;
use Spatie\Multitenancy\Models\Tenant;
use Spatie\Multitenancy\Tasks\SwitchTenantTask;
use Laravel\Passport\Passport;
class PassportTask implements SwitchTenantTask
{
public function __construct()
{
//
}
public function makeCurrent(Tenant $tenant): void
{
$this->setTenantPassport($tenant);
}
public function forgetCurrent(): void
{
$this->setTenantPassport();
}
protected function setTenantPassport(?Tenant $tenant = null): void
{
Passport::useTokenModel(TokenTenantAware::class);
Passport::useClientModel(ClientTenantAware::class);
Passport::useAuthCodeModel(AuthCodeTenantAware::class);
Passport::usePersonalAccessClientModel(PersonalAccessClientTenantAware::class);
}
}
from laravel-multitenancy.
Ah, hold up. This is the culprit methinks (in the default Passport migrations):
public function getConnection()
{
return config('passport.storage.database.connection');
}
from laravel-multitenancy.
I published the Passport config and set the connection to 'tenant', migrations ran properly. However, NOW I'm getting an error when trying to create a token for the user:
Class 'App\Tasks\PersonalAccessClientTenantAware' not found
when trying
$token = $user->createToken('API')->accessToken;
from laravel-multitenancy.
Oh God. Nothing to see here. Forgot to import classes. Thanks @masterix21 .
from laravel-multitenancy.
Related Issues (20)
- 3.0.2 crashes on using dispatchSync() with database transactions HOT 6
- Queue driver 'sync' generates "Call to a member function prepare() on null" HOT 4
- Tenant finder not running in tests HOT 1
- Queue Job Batching HOT 17
- Queue is not working after upgrading Laravel Framework to 9.34+
- SQL error when trying to use landlord database HOT 3
- Support for custom primary key on Tenant model HOT 1
- How can I access all tenant data at once?
- Tenant Not Set (Vapor + Octane) HOT 1
- Current tenant not determined when dispatching queued closures HOT 6
- When dispatching a Tenant Aware Job in sync mode from a test, any prior/current DB transaction is cleared HOT 2
- Model ignore tenant when add Observer HOT 2
- Tenant password reset token is being stored on landlord password_reset_tokens table HOT 1
- Prefixing cache doesn't work fine with file-store HOT 3
- Conflict with Rabbitmq package from vyuldashev HOT 1
- Scheduler : Large (longer) jobs, multiple tenants, stops.
- Tenant-Aware Job Scheduling with Horizon HOT 3
- MakeQueueTenantAwareAction seems to break active requests when Queue Connection is sync HOT 4
- base table or view not found with AWS SQS queue for job TenantAware HOT 12
- randomly receive Invalid catalog name: 1046 No database selected (Connection: mysql, SQL: insert into failed_jobs (uuid, connection, queue, payload, exception, failed_at) on queue sqs HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-multitenancy.