Skip to content

Commit 04b9d9f

Browse files
Merge pull request #1 from creativetimofficial/master
New improves
2 parents 28b05c3 + 80a323b commit 04b9d9f

File tree

6 files changed

+537
-297
lines changed

6 files changed

+537
-297
lines changed

readme.md

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ After initializing a fresh instance of Laravel (and making all the necessary con
5353

5454
Register a user or login using **admin@white.com** and **secret** and start testing the preset (make sure to run the migrations and seeders for these credentials to be available).
5555

56-
Besides the dashboard and the auth pages this preset also has a user management example and an edit profile page. All the necessary files (controllers, requests, views) are installed out of the box and all the needed routes are added to `routes/web.php`. Keep in mind that all of the features can be viewed once you login using the credentials provided above or by registering your own user.
56+
Besides the dashboard and the auth pages this preset also has an edit profile page. All the necessary files (controllers, requests, views) are installed out of the box and all the needed routes are added to `routes/web.php`. Keep in mind that all of the features can be viewed once you login using the credentials provided above or by registering your own user.
5757

5858
### Dashboard
5959

@@ -86,56 +86,6 @@ public function rules()
8686
];
8787
}
8888
```
89-
90-
### User management
91-
92-
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.
93-
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:
94-
95-
```
96-
<div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
97-
<label class="form-control-label" for="input-name">{{ __('Name') }}</label>
98-
<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>
99-
100-
@if ($errors->has('name'))
101-
<span class="invalid-feedback" role="alert">
102-
<strong>{{ $errors->first('name') }}</strong>
103-
</span>
104-
@endif
105-
</div>
106-
```
107-
108-
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.
109-
110-
```
111-
public function rules()
112-
{
113-
return [
114-
'name' => [
115-
'required', 'min:3'
116-
],
117-
'email' => [
118-
'required', 'email', Rule::unique((new User)->getTable())->ignore($this->route()->user->id ?? null)
119-
],
120-
'password' => [
121-
$this->route()->user ? 'required_with:password_confirmation' : 'required', 'nullable', 'confirmed', 'min:6'
122-
],
123-
];
124-
}
125-
```
126-
127-
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).
128-
129-
All the sample code for the user management can be found in `App\Http\Controllers\UserController`. See store method example bellow:
130-
131-
```
132-
public function store(UserRequest $request, User $model)
133-
{
134-
$model->create($request->merge(['password' => Hash::make($request->get('password'))])->all());
135-
136-
return redirect()->route('user.index')->withStatus(__('User successfully created.'));
137-
}
138-
```
13989
## Table of Contents
14090

14191
* [Versions](#versions)

src/white-stubs/app/Http/Controllers/UserController.php

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,78 +18,4 @@ public function index(User $model)
1818
{
1919
return view('users.index', ['users' => $model->paginate(15)]);
2020
}
21-
22-
/**
23-
* Show the form for creating a new user
24-
*
25-
* @return \Illuminate\View\View
26-
*/
27-
public function create()
28-
{
29-
return view('users.create');
30-
}
31-
32-
/**
33-
* Store a newly created user in storage
34-
*
35-
* @param \App\Http\Requests\UserRequest $request
36-
* @param \App\User $model
37-
* @return \Illuminate\Http\RedirectResponse
38-
*/
39-
public function store(UserRequest $request, User $model)
40-
{
41-
$model->create($request->merge(['password' => Hash::make($request->get('password'))])->all());
42-
43-
return redirect()->route('user.index')->withStatus(__('User successfully created.'));
44-
}
45-
46-
/**
47-
* Show the form for editing the specified user
48-
*
49-
* @param \App\User $user
50-
* @return \Illuminate\View\View
51-
*/
52-
public function edit(User $user)
53-
{
54-
if ($user->id == 1) {
55-
return redirect()->route('user.index');
56-
}
57-
58-
return view('users.edit', compact('user'));
59-
}
60-
61-
/**
62-
* Update the specified user in storage
63-
*
64-
* @param \App\Http\Requests\UserRequest $request
65-
* @param \App\User $user
66-
* @return \Illuminate\Http\RedirectResponse
67-
*/
68-
public function update(UserRequest $request, User $user)
69-
{
70-
$hasPassword = $request->get('password');
71-
$user->update(
72-
$request->merge(['password' => Hash::make($request->get('password'))])
73-
->except([$hasPassword ? '' : 'password']
74-
));
75-
76-
return redirect()->route('user.index')->withStatus(__('User successfully updated.'));
77-
}
78-
79-
/**
80-
* Remove the specified user from storage
81-
*
82-
* @param \App\User $user
83-
* @return \Illuminate\Http\RedirectResponse
84-
*/
85-
public function destroy(User $user)
86-
{
87-
if ($user->id == 1) {
88-
return abort(403);
89-
}
90-
91-
$user->delete();
92-
93-
return redirect()->route('user.index')->withStatus(__('User successfully deleted.'));
94-
}
9521
}

src/white-stubs/resources/views/pages/upgrade.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</tr>
3535
<tr>
3636
<td>Users management</td>
37-
<td class="text-center"><i class="fa fa-check text-success"></i></td>
37+
<td class="text-center"><i class="fa fa-times text-danger"></i></td>
3838
<td class="text-center"><i class="fa fa-check text-success"></i></td>
3939
</tr>
4040
<tr>

src/white-stubs/resources/views/users/create.blade.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/white-stubs/resources/views/users/edit.blade.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)