我正在使用PHP7在Ubuntu 16.04服务器上运行laravel 5.4.试图安装cviebrock/eloquent-sluggable
包抛出一些错误:
pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^4.2 for cviebrock/eloquent-sluggable
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/php-code-coverage 4.0.7 requires ext-dom * -> the requested …
Run Code Online (Sandbox Code Playgroud) 在W3Schools,他们声明两者|
并^
表示:选择具有以指定值开头的属性的元素.
那有什么区别?
我有一个默认值的函数,如下所示:
function f(a, b = 'something') {
//do stuff
}
Run Code Online (Sandbox Code Playgroud)
这很好用,但如果我尝试使用在线相关应用程序缩小我的JS文件,则会出现错误:
错误:意外的令牌运算符'=',预期的punc','
据我所知,使用Javascript=
设置默认值是合法的,为什么我会收到此错误?
我是否必须在函数体中定义默认值?
laravel 5.2 File
与Storage
外墙之间是否有任何差异?
看起来他们都使用相同的合同.我File
在laravel文档中看不到任何文档.如果它们不同,它们之间可能相互影响?
我尝试过以下mime类型来验证PDF文件.但是没有一个没有通过验证.
$rules = [
....
"file" => "required|mimes:application/pdf, application/x-pdf,application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf|max:10000"
....
]
Run Code Online (Sandbox Code Playgroud) 我的机器正在运行win7 64bit.我安装了Cygwin并添加C:\cygwin64\bin
到了PATH
.现在linux命令可以在cmd上运行,但是export
无法识别:
'export'不被识别为内部或外部命令,可操作程序或批处理文件.
而它在Cygwin64终端中正常工作.我应该如何将其添加到Windows默认cmd?
Laravel验证sometimes|required|email
和之间的区别是什么sometimes|email
?我从laracasts读过这个讨论,但对我来说它仍然含糊不清
有一个UpdateUserRequest
表单请求,它根据在rules
mathod中定义的规则验证字段值.默认情况下,它具有rules()和authorize()方法.我想阻止验证和更新空字段(如密码).
sometimes
在规则中使用是没有用的,因为html输入将出现在POST请求中,即使它们是空的.
array:6 [?
"_method" => "PATCH"
"_token" => "Cz79rRez2f6MG0tTU17nVwXD0X1lNGH1hA7OORjm"
"name" => "john"
"email" => "mymail@gmail.com"
"password" => ""
"password_confirmation" => ""
]
Run Code Online (Sandbox Code Playgroud)
所以我应该在使用sometimes
规则之前删除POST请求的空键.
问题是:清除Request数组的最佳位置在哪里?
是否有任何laravel构建方法来管理这种情况?
PS:解决方法:
@Bogdon解决方案仍然有效工作,但还有另一种古朴,美观大方,利落从采用的解决方案在这里:
只是覆盖all()
形式要求内部方法
class RegistrationRequest extends Request
{
...
public function all()
{
$attributes = parent::all();
if(isset($attributes['password']) && empty($attributes['password']))
{
unset($attributes['password']);
}
$this->replace($attributes);
return parent::all();
}
...
}
Run Code Online (Sandbox Code Playgroud) laravel ×6
validation ×3
android ×1
batch-file ×1
cmd ×1
composer-php ×1
css ×1
css3 ×1
cygwin ×1
export ×1
facade ×1
file ×1
javascript ×1
jobs ×1
laravel-5.4 ×1
mime ×1
minify ×1
php-7 ×1
queue ×1
request ×1
required ×1
rules ×1
storage ×1
windows ×1