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

Tenant aware resources #6

Open
vpratfr opened this issue Dec 13, 2018 · 0 comments
Open

Tenant aware resources #6

vpratfr opened this issue Dec 13, 2018 · 0 comments

Comments

@vpratfr
Copy link

vpratfr commented Dec 13, 2018

Here is how you can hide resources when switched to a tenant or to the system tenant in Nova using #5

Some traits

trait TenantAwareResource
{
    public static function availableForNavigation(Request $request)
    {
        $isTenantResource = static::$system === false;
        $isCustomerTenant = optional(app(Environment::class)->website())->is_admin_tenant !== true ?? false;

        return ($isTenantResource && $isCustomerTenant)
               || (!$isTenantResource && !$isCustomerTenant);
    }
}

trait IsSystemResource
{
    use TenantAwareResource;

    protected static $system = true;
}

trait IsTenantResource
{
    use TenantAwareResource;

    protected static $system = false;
}

Then you simply need to use the trait in your resources to show/hide them based on the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant