Bootstrap User Management
The theme comes with an out of the box user management option. To access this option, click the “Laravel Examples/Users Management” link in the left sidebar or add /laravel-examples/users-management
to the URL. The first thing you will see is a list of existing users. You can add new ones by clicking the “Add user” button (above the table on the right). On the Add user page, you will find a form which allows you to fill out the user`s name, email, role and password.
The store used for users form can be found in app/Http/Controllers/UserController
You can find the functions for users form in resources/views/laravel-examples/user
folder.
Once you add more users, the list will grow and for every user you will have edit and delete options.
User Controller
public function store(Request $request)
{
$request->validate([
'name' => 'required|min:3|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:7|confirmed|max:255',
'role_id' => 'required|integer|between:1,3',
'profile_picture' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
], [
'name.required' => 'Name is required',
'email.required' => 'Email is required',
'password.required' => 'Password is required',
'role_id.required' => 'Role is required'
]);
$picture = $request->file('profile_picture');
$photoPath = $picture ? '/storage/' . $picture->store('profile', 'public') : 'assets/img/default-avatar.png';
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'role_id' => $request->role_id,
'profile_picture' => $photoPath
]);
return redirect(route('users-management'))->with('success', 'New member added successfully.');
}