1 year ago

/panel/users/{id}/edit and /panel/profile

Posted 1 year ago by zefex

I'm creating a panel for both the user and the admin, I created a resource route for users where I can edit an user by going to /panel/users/{id}/edit, this page will have the form for the user editing. In the panel page I have a menu with the @role('admin') to check if the current user is an admin, if he is I will have the user management links in place (for editing, creating, listing, etc). The thing is: if the current logged user is not an admin I wanted to display the profile so he can edit his profile information. Right now I'm doing something like <a href="{{ route('panel.users.edit', ['id' => auth()->user()->id]) }}">Profile</a> but I don't want that way. I was wondering, is it possible to make some kind of /panel/profile route that would load the same view without the need to pass the id as query?

The other REALLY important thing is: I need to know in the view if the user is editing his profile or an admin editing someone's else profile because in the admin view I need to add more fields such as roles and things like that that usually a regular user can't change. How can I do something like that? Thank you.

Please sign in or create an account to participate in this conversation.