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
d8592274
Commit
d8592274
authored
Sep 08, 2022
by
20194288-huannh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
register + login
parent
67a68f45
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
167 additions
and
169 deletions
+167
-169
UserController.php
example-app/app/Http/Controllers/UserController.php
+36
-0
User.php
example-app/app/Models/User.php
+5
-35
login.blade.php
example-app/resources/views/login.blade.php
+51
-0
register.blade.php
example-app/resources/views/register.blade.php
+64
-0
welcome.blade.php
example-app/resources/views/welcome.blade.php
+0
-132
web.php
example-app/routes/web.php
+11
-2
No files found.
example-app/app/Http/Controllers/UserController.php
0 → 100644
View file @
d8592274
<?php
namespace
App\Http\Controllers
;
use
App\Http\Controllers\Controller
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
// use App\Http\Request;
class
UserController
extends
Controller
{
public
function
index
(){
}
public
function
register
(
Request
$request
){
if
(
$request
->
rule
)
{
return
"Bạn phải chấp nhận điều khoản mới có thể đăng kí"
;
}
$user
=
new
User
();
$user
->
name
=
$request
->
name
;
$user
->
phone
=
$request
->
phone
;
$user
->
password
=
md5
(
$request
->
password
);
$user
->
save
();
}
public
function
login
(
Request
$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
example-app/app/Models/User.php
View file @
d8592274
...
@@ -3,42 +3,12 @@
...
@@ -3,42 +3,12 @@
namespace
App\Models
;
namespace
App\Models
;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Foundation\Auth\User
as
Authenticatable
;
use
Illuminate\Notifications\Notifiable
;
use
Laravel\Sanctum\HasApiTokens
;
class
User
extends
Authenticatable
class
User
extends
Model
{
{
use
HasApiTokens
, HasFactory, Notifiable
;
public
$timestamps
=
FALSE
;
protected
$table
=
'users'
;
protected
$fillable
=
[
'phone'
,
'name'
,
'password'
];
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected
$fillable
=
[
'name'
,
'email'
,
'password'
,
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected
$hidden
=
[
'password'
,
'remember_token'
,
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected
$casts
=
[
'email_verified_at'
=>
'datetime'
,
];
}
}
example-app/resources/views/login.blade.php
0 → 100644
View file @
d8592274
<!DOCTYPE html>
<html
lang=
"{{ str_replace('_', '-', app()->getLocale()) }}"
>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Laravel
</title>
<!-- Fonts -->
<link
href=
"https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap"
rel=
"stylesheet"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz"
crossorigin=
"anonymous"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"
></script>
<!-- Styles -->
<style>
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
</style>
<style>
body
{
font-family
:
'Nunito'
,
sans-serif
;
}
</style>
</head>
<body>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-5"
>
<form
method=
"POST"
action=
"/login"
>
<h2>
Đăng nhập
</h2>
<div
class=
"form-group"
>
<label>
Số điện thoại (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
</div>
<div
class=
"form-group"
>
<label>
Mật khẩu (*)
</label>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
</div>
<div
class=
"form-group"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
</div>
<div
class=
"form-group"
>
<button
class=
"btn btn-success"
>
Đăng nhập
</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
example-app/resources/views/register.blade.php
0 → 100644
View file @
d8592274
<!DOCTYPE html>
<html
lang=
"{{ str_replace('_', '-', app()->getLocale()) }}"
>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
Laravel
</title>
<!-- Fonts -->
<link
href=
"https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap"
rel=
"stylesheet"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz"
crossorigin=
"anonymous"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"
></script>
<!-- Styles -->
<style>
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
</style>
<style>
body
{
font-family
:
'Nunito'
,
sans-serif
;
}
</style>
</head>
<body>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-5"
>
<form
method=
"POST"
action=
"/register"
>
@csrf
<h2>
Đăng kí
</h2>
<div
class=
"form-group"
>
<label>
Số điện thoại (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"phone"
>
</div>
<div
class=
"form-group"
>
<label>
Họ Tên (*)
</label>
<input
type=
"text"
placeholder=
""
require
class=
"form-control"
name=
"name"
>
</div>
<div
class=
"form-group"
>
<label>
Mật khẩu (*)
</label>
<input
type=
"password"
placeholder=
""
require
class=
"form-control"
name=
"password"
>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"register"
>
<label>
Đăng kí cửa hàng
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"checkbox"
name=
"rule"
>
<label>
Tôi đồng ý với điều khoản sử dụng
</label>
</div>
<div
class=
"form-group"
>
<input
type=
"hidden"
name=
"_token"
value=
"
<?php
echo
csrf_token
()
?>
"
>
</div>
<div
class=
"form-group"
>
<button
class=
"btn btn-success"
>
Đăng kí
</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
example-app/resources/views/welcome.blade.php
deleted
100644 → 0
View file @
67a68f45
This diff is collapsed.
Click to expand it.
example-app/routes/web.php
View file @
d8592274
<?php
<?php
use
App\Http\Controllers\UserController
;
use
Illuminate\Support\Facades\Route
;
use
Illuminate\Support\Facades\Route
;
/*
/*
...
@@ -12,7 +13,15 @@
...
@@ -12,7 +13,15 @@
| contains the "web" middleware group. Now create something great!
| contains the "web" middleware group. Now create something great!
|
|
*/
*/
Route
::
post
(
'/register'
,
[
UserController
::
class
,
'register'
]);
Route
::
get
(
'/'
,
function
()
{
Route
::
get
(
'/
register
'
,
function
()
{
return
view
(
'
welcome
'
);
return
view
(
'
register
'
);
});
});
Route
::
get
(
'/login'
,
function
()
{
return
view
(
'login'
);
});
Route
::
post
(
'/login'
,
[
UserController
::
class
,
'login'
]);
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