Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
P
Project_Laravel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Nguyen Huu Huan
Project_Laravel
Commits
961ddb96
Commit
961ddb96
authored
Sep 10, 2022
by
Le Dinh Trung
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/validation' into 'dev'
Feature/validation See merge request
!3
parents
64e28c2c
14cb17b6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
0 deletions
+140
-0
UserController.php
app/Http/Controllers/UserController.php
+36
-0
LoginRequest.php
app/Http/Requests/LoginRequest.php
+41
-0
RegisterRequest.php
app/Http/Requests/RegisterRequest.php
+45
-0
login.blade.php
resources/views/login.blade.php
+6
-0
register.blade.php
resources/views/register.blade.php
+12
-0
No files found.
app/Http/Controllers/UserController.php
0 → 100644
View file @
961ddb96
<?php
namespace
App\Http\Controllers
;
use
App\Http\Controllers\Controller
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
use
App\Http\Requests\LoginRequest
;
use
App\Http\Requests\RegisterRequest
;
// use App\Http\Request;
class
UserController
extends
Controller
{
public
function
index
(){
}
public
function
register
(
RegisterRequest
$request
){
$user
=
new
User
();
$user
->
name
=
$request
->
name
;
$user
->
phone
=
$request
->
phone
;
$user
->
password
=
md5
(
$request
->
password
);
$user
->
save
();
}
public
function
login
(
LoginRequest
$request
){
$user
=
User
::
where
(
'phone'
,
$request
->
phone
)
->
get
();
for
(
$i
=
0
;
$i
<
count
(
$user
);
$i
++
){
if
(
$user
[
$i
]
->
password
==
md5
(
$request
->
password
))
return
'Login success'
;
else
return
'Login fail'
;
}
}
}
?>
\ No newline at end of file
app/Http/Requests/LoginRequest.php
0 → 100644
View file @
961ddb96
<?php
namespace
App\Http\Requests
;
use
Illuminate\Foundation\Http\FormRequest
;
class
LoginRequest
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
true
;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public
function
rules
()
{
return
[
'phone'
=>
'required|min:9'
,
'password'
=>
'required|min:6'
,
];
}
public
function
messages
()
{
return
[
'phone.required'
=>
'Bắt buộc phải nhập trường này'
,
'phone.min'
=>
'Số kí tự tối thiểu là 9'
,
'password.required'
=>
'Bắt buộc phải nhập trường này'
,
'password.min'
=>
'Số kí tự tối thiểu là 6'
];
}
}
app/Http/Requests/RegisterRequest.php
0 → 100644
View file @
961ddb96
<?php
namespace
App\Http\Requests
;
use
Illuminate\Foundation\Http\FormRequest
;
class
RegisterRequest
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
true
;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public
function
rules
()
{
return
[
'phone'
=>
'required|min:9'
,
'password'
=>
'required|min:6'
,
'name'
=>
'required'
,
'rule'
=>
'required'
];
}
public
function
messages
()
{
return
[
'phone.required'
=>
'Bắt buộc phải nhập trường này'
,
'phone.min'
=>
'Số kí tự tối thiểu là 9'
,
'password.required'
=>
'Bắt buộc phải nhập trường này'
,
'password.min'
=>
'Số kí tự tối thiểu là 6'
,
'name.required'
=>
'Bắt buộc phải nhập trường này'
,
'rule.required'
=>
'Bạn phải đồng ý điều khoản mới có thể đăng kí'
];
}
}
resources/views/login.blade.php
View file @
961ddb96
...
@@ -33,10 +33,16 @@
...
@@ -33,10 +33,16 @@
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Số điện thoại (*)
</label>
<label
class=
"form-label"
>
Số điện thoại (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
@error('phone')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Mật khẩu (*)
</label>
<label
class=
"form-label"
>
Mật khẩu (*)
</label>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
@error('password')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
...
...
resources/views/register.blade.php
View file @
961ddb96
...
@@ -33,14 +33,23 @@
...
@@ -33,14 +33,23 @@
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Số điện thoại (*)
</label>
<label
class=
"form-label"
>
Số điện thoại (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
@error('phone')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Họ Tên (*)
</label>
<label
class=
"form-label"
>
Họ Tên (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"name"
>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"name"
>
@error('name')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<label
class=
"form-label"
>
Mật khẩu (*)
</label>
<label
class=
"form-label"
>
Mật khẩu (*)
</label>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
@error('password')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"register"
>
<input
type=
"checkbox"
name=
"register"
>
...
@@ -49,6 +58,9 @@
...
@@ -49,6 +58,9 @@
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<input
type=
"checkbox"
name=
"rule"
>
<input
type=
"checkbox"
name=
"rule"
>
<label>
Tôi đồng ý với điều khoản sử dụng
</label>
<label>
Tôi đồng ý với điều khoản sử dụng
</label>
@error('rule')
<span
class=
"text text-danger"
>
{{$message}}
</span>
@enderror
</div>
</div>
<div
class=
"form-group mb-3"
>
<div
class=
"form-group mb-3"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment