File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Miracuthbert \Multitenancy ;
44
5+ use Closure ;
56use Miracuthbert \Multitenancy \Traits \TenancyDriverTrait ;
67
78class Tenancy
@@ -50,6 +51,33 @@ public function tenant()
5051 return $ this ->manager ()->getTenant ();
5152 }
5253
54+ /**
55+ * Carry out non-tenant tasks and resume tenant session when done.
56+ *
57+ * @return mixed
58+ */
59+ public function runNonTenantTask (Closure $ callable )
60+ {
61+ $ tenant = $ this ->manager ()->getTenant ();
62+
63+ $ this ->manager ()->clearTenant ();
64+
65+ $ callable ();
66+
67+ $ this ->setTenant ($ tenant );
68+ }
69+
70+ /**
71+ * Set tenant for session or request.
72+ *
73+ * @param \Miracuthbert\Multitenancy\Models\Tenant $tenant
74+ * @return void
75+ */
76+ public function setTenant ($ tenant )
77+ {
78+ $ this ->manager ()->setTenant ($ tenant );
79+ }
80+
5381 /**
5482 * Get an instance of the tenant config helper.
5583 *
You can’t perform that action at this time.
0 commit comments