我在创建新用户时使用以下规则进行验证:
protected $rules= [
'name' => 'required',
'email' => [
'required',
'unique:user',
'email'
]
];
Run Code Online (Sandbox Code Playgroud)
更新现有用户时,我使用与上面所示相同的规则集,但如果用户根本没有更改其电子邮件,则不希望出现验证错误.
我目前通过使用以下方法解决此问题:
if (!User::changed('email')) {
unset($user->email);
}
Run Code Online (Sandbox Code Playgroud)
对我来说这感觉就像一个肮脏的解决方法,所以我想知道是否有更好的选择.
还要注意,这个changed方法是我自己写的.有没有人知道是否有一个用于检查模型属性是否已更改的本机Laravel 4方法?
谢谢!
nginx 新手,在重写时遇到了一些问题。
我有一个链接到子域 test.mydomain.com 的网站。我当前的 nginx 配置:
server {
listen 80 default_server;
root /test/public;
index index.html index.htm index.php;
server_name localhost;
access_log /var/log/nginx/localhost.laravel-access.log;
error_log /var/log/nginx/locahost.laravel-error.log error;
charset utf-8;
location /admin/ {
alias /test/public/admin/public/;
try_files $uri $uri/ /admin/index.php?$query_string;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
error_page 404 /index.php;
include hhvm.conf; # The HHVM Magic Here
# Deny .htaccess file access
location ~ …Run Code Online (Sandbox Code Playgroud)