Skip to content

Commit bc39ae6

Browse files
committed
Finish user signup
1 parent 0ec7dc0 commit bc39ae6

File tree

19 files changed

+467
-6
lines changed

19 files changed

+467
-6
lines changed

app/Http/Controllers/UsersController.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,36 @@
77
use App\Http\Requests;
88
use App\Http\Controllers\Controller;
99

10+
use App\Models\User;
11+
1012
class UsersController extends Controller
1113
{
1214
public function create()
1315
{
1416
return view('users.create');
1517
}
18+
19+
public function show($id)
20+
{
21+
$user = User::findOrFail($id);
22+
return view('users.show', compact('user'));
23+
}
24+
25+
public function store(Request $request)
26+
{
27+
$this->validate($request, [
28+
'name' => 'required|max:50',
29+
'email' => 'required|email|unique:users|max:255',
30+
'password' => 'required|confirmed|min:6'
31+
]);
32+
33+
$user = User::create([
34+
'name' => $request->name,
35+
'email' => $request->email,
36+
'password' => $request->password,
37+
]);
38+
39+
session()->flash('success', '欢迎,您将在这里开启一段新的旅程~');
40+
return redirect()->route('users.show', [$user]);
41+
}
1642
}

app/Http/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
get('/about', 'StaticPagesController@about')->name('about');
66

77
get('signup', 'UsersController@create')->name('signup');
8+
resource('users', 'UsersController');

app/Models/User.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,15 @@ class User extends Model implements AuthenticatableContract,
3636
* @var array
3737
*/
3838
protected $hidden = ['password', 'remember_token'];
39+
40+
public function gravatar($size = '100')
41+
{
42+
$hash = md5(strtolower(trim($this->attributes['email'])));
43+
return "http://www.gravatar.com/avatar/$hash?s=$size";
44+
}
45+
46+
public function setPasswordAttribute($password)
47+
{
48+
$this->attributes['password'] = bcrypt($password);
49+
}
3950
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"type": "project",
77
"require": {
88
"php": ">=5.5.9",
9-
"laravel/framework": "5.1.*"
9+
"laravel/framework": "5.1.*",
10+
"caouecs/laravel-lang": "~3.0"
1011
},
1112
"require-dev": {
1213
"fzaninotto/faker": "~1.4",

composer.lock

Lines changed: 42 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
|
5353
*/
5454

55-
'locale' => 'en',
55+
'locale' => 'zh-CN',
5656

5757
/*
5858
|--------------------------------------------------------------------------

public/css/app.css

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/app.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets/sass/app.scss

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,60 @@ footer ul li {
9797
float: left;
9898
margin-left: 15px;
9999
}
100+
101+
/* sidebar */
102+
103+
aside {
104+
section {
105+
padding: 10px 0;
106+
margin-top: 20px;
107+
&:first-child {
108+
border: 0;
109+
padding-top: 0;
110+
}
111+
span {
112+
display: block;
113+
margin-bottom: 3px;
114+
line-height: 1;
115+
}
116+
}
117+
}
118+
119+
section.user_info {
120+
padding-bottom: 10px;
121+
margin-top: 20px;
122+
text-align: center;
123+
.gravatar {
124+
float: none;
125+
max-width: 70px;
126+
}
127+
h1 {
128+
font-size: 1.4em;
129+
letter-spacing: -1px;
130+
margin-bottom: 3px;
131+
margin-top: 15px;
132+
}
133+
}
134+
135+
.gravatar {
136+
float: left;
137+
margin-right: 10px;
138+
max-width: 50px;
139+
border-radius: 50%;
140+
}
141+
142+
/* forms */
143+
144+
input, textarea, select, .uneditable-input {
145+
border: 1px solid #bbb;
146+
width: 100%;
147+
margin-bottom: 15px;
148+
}
149+
150+
input {
151+
height: auto !important;
152+
}
153+
154+
.panel {
155+
margin-top: 50px;
156+
}

resources/lang/zh-CN/auth.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Authentication Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are used during authentication for various
11+
| messages that we need to display to the user. You are free to modify
12+
| these language lines according to your application's requirements.
13+
|
14+
*/
15+
16+
'failed' => '用户名或密码错误。',
17+
'throttle' => '您的尝试登录次数过多. 请 :seconds 秒后再试。',
18+
19+
];

resources/lang/zh-CN/pagination.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Pagination Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are used by the paginator library to build
11+
| the simple pagination links. You are free to change them to anything
12+
| you want to customize your views to better match your application.
13+
|
14+
*/
15+
16+
'previous' => '&laquo; 上一页',
17+
'next' => '下一页 &raquo;',
18+
19+
];

resources/lang/zh-CN/passwords.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Password Reminder Language Lines
8+
|--------------------------------------------------------------------------
9+
|
10+
| The following language lines are the default lines which match reasons
11+
| that are given by the password broker for a password update attempt
12+
| has failed, such as for an invalid token or invalid new password.
13+
|
14+
*/
15+
16+
'password' => '密码至少是六位字符并且匹配。',
17+
'reset' => '密码重置成功!',
18+
'sent' => '密码重置邮件已发送!',
19+
'token' => '密码重置令牌无效。',
20+
'user' => '找不到该邮箱对应的用户。',
21+
22+
];

0 commit comments

Comments
 (0)