//控制器層
<?php
namespace app\http\controllers\admin;
u app\models\admin\urs;
u illuminate\http\request as request;
u app\http\controllers\controller;
u app\http\requests\register;
u illuminate\support\facades\db;
class urcontroller extends controller
{
public function login()
{
return view('admin.login');
}
public function login_do(request $request){
$model = new urs();
if ($model->lo($request->only('email','password'))){
return redirect()->route('admin.showlist')->with('msg','登錄成功');
}
}
public function register()
{
return view('admin.register');
}
public f铁军是什么意思unction register_do(register $request)
{
$model = new urs();
if ($model->zhuce($request->all())){
return redirect()->route('admin.login')->with('msg','用戶已註冊成功');
}
}
//模型層
<?php
namespace app\models\admin;
u illuminate\databa\eloquent\model;
u illuminate\foundation\aurebelledth\ur as authors;
class urs extends authors
{
public $table = "urs";
public function zhuce($data)
{
$this->urname =$data['urname'];
$this->password =bcrypt($data['password']);
$this->email =$data['email'];
return $this->save();
}
public function lo($data)
{
if (auth()->attempt($data)){
return auth()->ur();
}
}
}
//視圖層
//註冊頁面
@extends('layouts.app')
@ction('title','註冊頁面')
@ction('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('register') }}</div>
<div class="card-body">
<form method="post" action="{{ route('admin.register_do') }}" aria-label="{{ __('register') }}">
@csrf
<div class="form-group row">
<label for="urname" class="col-md-4 col-form-label text-md-right">{{ __('urname') }}</label>
<div class="col-md-6">
<input id="urname" type="text" class="form-control{{ $errors->has('urname') ? ' is-invalid' : '' }}" name="urname" value="{{ old('urname') }}" required autofocus>
@if ($errors->has('urname'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('urname') }}</strong>
表示走的词语有 </span>
@endif
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('e-mail address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('confirm password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offt-md-4">
<button type="submit" class="btn btn-primary">
{{ __('register') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endction
//登錄頁面
@extends('layouts.app')
@ction('title','登錄頁面')
@ction('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ ssion('msg' ?? 'login') }}</div>
<div class="card-body">
<form method="post" action="{{ route('admin.login_do') }}" aria-label="{{ __('login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('e-mail address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
计算机及 <div class="col-md-6 offt-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('remember me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offt-md-4">
<button type="submit" class="btn btn-primary">
{{ __('login') }}
</button>
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('forgot your password?') }}
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endction
//佈局頁面 layouts
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getlocale()) }}">
<head>
<meta chart="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
学校活动方案 <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- csrf token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title')</title>
<!-- scripts -->
<script src="{{ ast('js/app.js') }}" defer></script>
<!-- fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=nunito" rel="stylesheet" type="text/css">
<!-- styles -->
<link href="{{ ast('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collap" data-target="#navbarsupportedcontent" aria-controls="navbarsupportedcontent" aria-expanded="fal" aria-label="{{ __('toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collap navbar-collap" id="navbarsupportedcontent">
<!-- left side of navbar -->
<ul class="navbar-nav mr-auto">
</ul>
<!-- right side of navbar -->
<ul class="navbar-nav ml-auto">
<!-- authentication links -->
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.login') }}">{{ __('login') }}</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.register') }}">{{ __('register') }}</a>
</li>
@el
<li class="nav-item dropdown">
<a id="navbardropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="fal" v-pre>
{{ auth::ur()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbardropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventdefault();
document.getelementbyid('logout-form').submit();">
{{ __('logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="post" style="display: none;">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
<main class="py-4">
@yield('content')
</main>
</div>
</body>
</html>
本文发布于:2023-04-07 07:23:28,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/ac19cb5482b8f3b2abe520fd214ca870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:laravel框架之自帶登錄&註冊.doc
本文 PDF 下载地址:laravel框架之自帶登錄&註冊.pdf
留言与评论(共有 0 条评论) |