Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper for global context #487

Closed
obrunsmann opened this issue Sep 1, 2020 · 4 comments · Fixed by #526
Closed

Helper for global context #487

obrunsmann opened this issue Sep 1, 2020 · 4 comments · Fixed by #526
Assignees
Labels
feature New feature or request

Comments

@obrunsmann
Copy link

I suggest adding an helper to run some part of the code in global context. More or less an opposite to the run()-Method on tenant model.

Example:

global()->run(function() use($subscription) {
  $subscription('xx')->swap();
});

There are cases without access to the e.g. model so that I can't add the CentralConnection Trait to it. Specifically I have that problem with the cashier-mollie package which does not yet provide a functionality to customize the models (laravel/cashier-mollie#146).

I have to run the swap method in global context to work.

@obrunsmann obrunsmann added the feature New feature or request label Sep 1, 2020
@christophheich
Copy link

Would be great to get such a global helper function.

@abhinay1435
Copy link

abhinay1435 commented Jul 21, 2021

Hello, @stancl
tenancy->central(function ($callback) {
User::all();
});
The Helper is great when we just need the full object of a table.

I tried to implement the following in my code and it was not working

$id = 1;
$admin_details= tenancy()->central(function ($id) {
return User::find($id);
});

This returned null
what is the go through for this
to pass id or any other variable or an object in the central function instead of $tenant

@stancl
Copy link
Member

stancl commented Jul 21, 2021

Please don't spam the repo and follow the issue templates.

@abhinay1435
Copy link

Apologies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
4 participants