如何在验证器中添加密码验证规则?
验证规则:
密码包含以下五个类别中至少三个的字符:
如何在验证器规则中添加上述规则?
我的代码在这里
// create the validation rules ------------------------
$rules = array(
'name' => 'required', // just a normal required validation
'email' => 'required|email|unique:ducks', // required and must be unique in the ducks table
'password' => 'required',
'password_confirm' => 'required|same:password' // required and has to match the password field
);
// do the validation ----------------------------------
// validate against the inputs from our form
$validator = Validator::make(Input::all(), $rules); …Run Code Online (Sandbox Code Playgroud) 我有以下JSON数据:{"success":"You are welcome"}我json在我的JavaScript代码中命名.
当我想提醒You are welcome我的时候json.success.所以现在我面临的问题是,如果我想提醒,那该怎么办success?有没有办法得到它?
通常我将以下图像用于 .net core 3.1 并且它工作正常。
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
Run Code Online (Sandbox Code Playgroud)
我出于实验原因启动了一个新的 .net 5 项目并创建dockerfile了以下内容
FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim AS base
FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build
Run Code Online (Sandbox Code Playgroud)
并有以下问题:
=> ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:5.0-buster 0.2s
=> ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim 0.2s
=> CANCELED [build 1/7] FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster 0.0s
=> => resolve mcr.microsoft.com/dotnet/core/sdk:5.0-buster 0.0s
=> [internal] load build context 0.0s
=> ERROR [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim 0.0s
=> => resolve mcr.microsoft.com/dotnet/core/aspnet:5.0-buster-slim
Run Code Online (Sandbox Code Playgroud) 我有两个GitHub存储库.
我想自动(可能使用钩子和/或github API)提交并将文件推送到第二个存储库,当它们被推送到第一个存储库时.
第二个存储库不是第一个存储库的克隆,它们的文件夹布局不一定相同,只有一堆共同的文件.
这样做最简单的方法是什么?
如果我不需要安装http服务器或学习perl,奖励积分:)
我已经从迁移创建了MySQL存储过程,它工作得很好.
DB::unprepared('
CREATE PROCEDURE sp_Create_Default_Task_1(IN _kid_id INT)
BEGIN
INSERT INTO tasks (kid_id, name) VALUES (_kid_id, \'daily\');
END'
);
Run Code Online (Sandbox Code Playgroud)
此后我尝试使用以下代码创建MySQL触发器
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTrigger extends Migration {
public function up()
{
DB::unprepared('
CREATE TRIGGER tr_Task_Default AFTER INSERT ON `kids` FOR EACH ROW
INSERT INTO tasks (`kid_id`, `name`) VALUES (NEW.id, \'Default\');
');
}
public function down()
{
DB::unprepared('DROP TRIGGER `tr_User_Default_Member_Role`');
}
}
Run Code Online (Sandbox Code Playgroud)
但它在我运行后返回错误 php artisan migrate
{"error":{"type":
"Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message":"Class 'CreateTriggers' not found",
"file":"C:\\xampp\\htdocs\\dev03\\vendor\\laravel\\framework
\\src\\Illuminate\\Database\\Migrations\\Migrator.php",
"line":301}}
Run Code Online (Sandbox Code Playgroud)
问题:出了什么问题?
我手动测试了我想要的场景:
管理员用户可以转到/codes该站点的部分.正常用户被重定向(302)回到/dashboard并且Sorry you are not allowed there在他们去的时候有消息/qr.
手动测试通过,但是laravel测试失败.
我在用 laravel 5.1
测试管理员用户:
public function testAdminViewCodes()
{
//create an admin user
$user = factory(App\User::class, 'admin')->create();
$this->actingAs($user)
->visit('/codes')
->seePageIs('/codes')
->see('Codes');
}
Run Code Online (Sandbox Code Playgroud)
测试普通用户:
public function testNormalViewCodesFail()
{
//create a normal user
$normal_user = factory(App\User::class)->create();
//TODO: Fix this failing test FFS
$this->actingAs($normal_user)
->visit('/qr')
->seePageIs('/dashboard')
->see('Sorry you are not allowed there');
}
Run Code Online (Sandbox Code Playgroud)
测试结果 ;
There was 1 failure:
1) AdminTest::testNormalViewQRCodesFail
Did not land on expected page [http://localhost/dashboard]. …Run Code Online (Sandbox Code Playgroud) 我有一个列表视图,其中包含我所有用户的列表.列表中的每个项目都是一个布局,其中包含一个按钮,用于显示AlertDialog以更改按钮标签的值.如何动态地将单击事件添加到listview适配器生成的按钮?
这是我的适配器:
public class PerfilAdapter extends BaseAdapter {
Context mContext;
LayoutInflater mLayoutInflater;
List<PerfilBean> listaPerfiles = new ArrayList<PerfilBean>();
public Settings01 set=new Settings01();
public PerfilAdapter(Context context,List<PerfilBean> lista) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listaPerfiles=lista;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return listaPerfiles.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return listaPerfiles.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View …Run Code Online (Sandbox Code Playgroud) 我已经安装了Laravel 5.0并进行了身份验证.一切都很好.
我的网站仅对经过身份验证的成员开放.内部内容仅受Authenticated成员保护,但站点内的图像不受公共视图保护.
任何人直接写图像URL都可以看到图像,即使该人没有登录到系统.
http://www.somedomainname.net/images/users/userImage.jpg
Run Code Online (Sandbox Code Playgroud)
我的问题:是否可以从公共视图保护图像(上面的URL示例),在其他Word中,如果图像的URL发送给任何人,则个人必须是成员并且登录才能看到图像.
这可能吗?怎么样?
我正在尝试制作一个允许上传文件并将其存储在应用程序的public/upload文件夹中的表单.
我的表格是:
<form action="/image/save" method="post">
<input name="image" type="file" />
<input type="submit" value="Save"/>
</form>
Run Code Online (Sandbox Code Playgroud)
和控制器:
public function save(){
$file = Input::file('image');
$destinationPath = 'upload/';
$filename = $file->getClientOriginalName();
Input::file('image')->move($destinationPath, $filename);
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我收到以下错误:调用getClientOriginalName()非对象上的成员函数
有没有办法用下面的div标签替换img标签?
原创html:
<div class="article">
<img src="/images/img-1.jpg" alt="alt for image">
</div>
Run Code Online (Sandbox Code Playgroud)
替换为html:
<div class="article">
<div style="background: transparent url(/images/img-1.jpg) no-repeat;
background-position: center center; background-size: cover; width: 566px;
height: 576px;">alt for image</div>
</div>
Run Code Online (Sandbox Code Playgroud)
(可选)也可以使用父div中的宽度和高度,即我的示例中的文章类而不是定义固定的width: 566px; height: 576px;?
如果可能,我想使用该str_replace功能.
str_replace('?????', '?????', $article);
Run Code Online (Sandbox Code Playgroud)
编辑:
可能有多个带有类文章的元素,并且文章类div中可能还有其他元素,我需要将img更改为div.
EDIT2:
我的意思是好像我可能在文章div中有任何内容,只是想用div替换img.
我可能有:
<div class="article">
<h1>heading</h1>
<p>paragraph</p>
<img src="/images/img-1.jpg" alt="alt for image">
</div>
Run Code Online (Sandbox Code Playgroud)
或者我可能有:
<div class="article">
<h3>heading</h3>
<p><img src="/images/img-1.jpg" alt="alt for image"> some paragraph </p>
</div>
Run Code Online (Sandbox Code Playgroud)
所以,我可能在.articlediv中有任何东西,我想从中将img替换为div
从:
<img src="/images/img-1.jpg" alt="alt for image" here-may-be-another-attribute-too> …Run Code Online (Sandbox Code Playgroud) laravel ×5
php ×5
laravel-5 ×4
laravel-5.1 ×2
.net-5 ×1
android ×1
css ×1
docker ×1
frameworks ×1
git ×1
githooks ×1
github ×1
github-api ×1
html ×1
javascript ×1
json ×1
laravel-4 ×1
laravel-5.2 ×1
laravel-5.3 ×1
listview ×1
migration ×1
triggers ×1
unit-testing ×1
validation ×1