标签:文件 消失 date inter com lan auth this class
就拿laravel的登入验证来举例:
1.进入login控制器,
use AuthenticatesUsers;从这里点进去
找到验证规则
//验证
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => ‘required|string‘,
‘password‘ => ‘required|string‘,
]);
}
放入login控制器中
2.进入laravel5.7文档验证那一节找到
@if ($errors->any()) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif
放入login模板中。如用其他UI可自行更改样式
例如amazeui
@if ($errors->any())
<div class="am-alert am-alert-danger" data-am-alert>
<button type="button" class="am-close">x</button>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
设定个JS定时消失
$(function () {
var action=(function(){
$(‘.am-close‘).click()
})
var id=setInterval(action,2000)
})
3.安装laravel语言包
跑命令composer require "overtrue/laravel-lang:~3.0"
config/app.php
中的下一行Illuminate\Translation\TranslationServiceProvider::class,
Overtrue\LaravelLang\TranslationServiceProvider::class,
config/app.php
:‘locale‘ => ‘zh-CN‘,
php artisan lang:publish zh-CN
5.ok!
标签:文件 消失 date inter com lan auth this class
原文地址:https://www.cnblogs.com/big2cat/p/10606618.html