User management

The preset comes with a user management option out of the box. To access this click the "User Management" link in the left sidebar or add /user to the url. The first thing you will see is the listing of the 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 see the form that allows you to do this. All pages are generate using blade templates:


              <div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
                  <label class="form-control-label" for="input-name">{{ __('Name') }}</label>
                  <input type="text" name="name" id="input-name" class="form-control form-control-alternative{{ $errors->has('name') ? ' is-invalid' : '' }}" placeholder="{{ __('Name') }}" value="{{ old('name') }}" required autofocus>
              
                  @if ($errors->has('name'))
                      <span class="invalid-feedback" role="alert">
                          <strong>{{ $errors->first('name') }}</strong>
                      </span>
                  @endif
              </div>
            

Also validation rules were added so you will know exactely what to enter in the form fields (see App\Http\Requests\UserRequest). Note that these validation rules also apply for the user edit option.


            public function rules()
            {
                return [
                    'name' => [
                        'required', 'min:3'
                    ],
                    'email' => [
                        'required', 'email', Rule::unique((new User)->getTable())->ignore($this->route()->user->id ?? null)
                    ],
                    'password' => [
                        $this->route()->user ?  'required_with:password_confirmation' : 'required', 'nullable', 'confirmed', 'min:6'
                    ]
                ];
            }
            

Once you add more users, the list will get bigger and for every user you will have edit and delete options (access these options by clicking the three dotted menu that appears at the end of every line).

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


          public function store(UserRequest $request, User $model)
          {
              $model->create($request->merge(['password' => bcrypt($request->get('password'))])->all());
  
              return redirect()->route('user.index')->withStatus(__('User successfully created.'));
          }