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

repository method not exposed to the User facade per docs for making custom user repository #1046

Closed
jimmypuckett opened this issue Dec 2, 2019 · 5 comments

Comments

@jimmypuckett
Copy link

On a fresh install on an existing Laravel 6 app, we are trying to make a custom user repository per the docs here...

https://statamic.dev/knowledge-base/storing-users-somewhere-custom

which says "In a service provider, use the Statamic\API\User::repository() method to define a custom repository driver:", but the code block has...

Statamic\Facades\User::repository('custom', function ($app, $config) {
    return new CustomUserRepository;
});

I do not see a Statamic\API\User class, and the abstract class Statamic\Contracts\Auth\UserRepository for the Statamic\Facades\User facade does not have a repository method defined.

The only place that I see a method called repository is in Statamic\Auth\UserRepositoryManager, which appears to be a getter for the repository, not a setter.

In our app, we use spatie/laravel-permission, and were planning on making a custom driver to leverage the roles & permissions already in the system, so we were planning on building a driver.

Anyhow, I cannot tell if this is an issue with the docs, the code or the user?

Thanks!

@edalzell
Copy link
Contributor

@damcclean you've done this recently right? Is this still an issue?

@jasonvarga
Copy link
Member

Looks like it's still an issue. It should be what the documentation says, but you can get around it until then by targeting the UserRepositoryManager.

app(\Statamic\Auth\UserRepositoryManager::class)->extend('custom', function ($app, $config) {
    return new CustomUserRepository;
});

@github-actions
Copy link

github-actions bot commented Jan 7, 2021

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

@okaufmann
Copy link
Contributor

@jasonvarga This is still incorrectly documented. Is there a way we can do this via Facades now?

@jasonvarga
Copy link
Member

Thanks for the nudge, I updated the docs.

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

No branches or pull requests

5 participants