creativetimofficial/ct-argon-dashboard-pro-laravel

How do I add a "Show" method for users?

Closed this issue · 4 comments

I'm working my way through the code to unwrap the middleware.

I want to implement the ability for the admin the simply view a user's details, not just edit or delete.

I've added the show() function to the UserController class and changed the routing from Route::resource('user', 'UserController', ['except' => ['show']]); to Route::resource('user', 'UserController'); but navigating to a user using the ID, e.g. 127.0.0.1:8000/user/1 just throws a 403 Forbidden Error.

Are there some additional changes to be made within the middleware? Do you have any documentation on it?

Hello, you need to add a view function to App/Policies/UserPolicy.php.

Do you mean...

public function show(User $user)
    {
        return $user->isAdmin();
    }

If so, tried that and still getting a 403 Error.

Managed to fix it, using the show method as view on the policy.

Hello @dutypro, thank you for letting us know.
Happy coding!