Laravel Sanctum and Laravel Permissions #2661
Unanswered
AleJavierHY
asked this question in
Q&A
Replies: 2 comments 2 replies
-
It's difficult to know whether the problem is with your Controller, or with your custom model, or any other place. Please post all the code necessary to recreate the problem on a new Laravel app. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Laravel Permissions to create a Roles system in my web application that uses Laravel for the backend and Quasar with Vue on the front end. I have an api route that points to the index function of RoleController and it returns all the roles with their respective permissions and users related to each role.
Everything works correctly until I assign the auth:sanctum middleware to the api route. It is at that moment that the errors begin, specifically with the users relationship of the Laravel Permissions package. I already verified that it is only this relationship that does not work when I am using the auth:sanctum middleware in the api route of the index function.
The error it returns is the following:
{ "message": "Class name must be a valid object or a string", "exception": "Error", "file": "D:\\1-TRABAJO\\PROYECTOS\\ZUNspad2.0\\backend\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasRelationships.php", "line": 793, }
Please, what could I be overlooking, I need to fix this error. The relationship exists and works but only when I do not use the auth:sanctum middlewareBeta Was this translation helpful? Give feedback.
All reactions