User Management

-
Pro Component

The Admin user has access to a users management table page.


The user management can be accessed by clicking User Management from the Laravel Examples section of the sidebar or adding /user-management in the url. This page is available for users with the Admin role and the user is able to add, edit and delete other users. For adding a new user you can press the + Add User button. If you would like to edit or delete an user you can click on the Action column. It is also possible to sort the fields or to search in the fields.

The policy which authorizes the user to access the user management pages is implemented in App\Policies\UserPolicy.php

Once you add more users, the list will grow and for every user you will have edit and delete options

All the sample code for the user management can be found in App/Http/Controllers/UserManagementController.php. See store method example bellow:

Copy

                      public function store(){

                        $attributes = request()->validate([
                            'email' => 'required|unique:users,email',
                            'name' =>'required|',
                            'password' => 'required|confirmed|min:7',
                            'picture' => 'required|mimes:jpg,jpeg,png,bmp,tiff |max:4096',
                            'role_id' => 'required|exists:roles,id',
                        ]);

                        $path = request()->picture->store('profile', 'public');
                        $attributes['picture'] = "$path";


                        User::create($attributes);

                        return redirect('users-management')->withStatus('User successfully created.');
                    }