因为我有保存和更新按钮,所以我需要知道在laravel上的请求表单中单击了哪个按钮.
App\Http\Requests\RegistrationRequest.php
public function rules()
{
$myrule = [ 'name' => 'required', 'age' => 'required' ];
if (isset($_POST['save']))
{
$myrule['application_form'] = 'required';
}
elseif (isset($_POST['update']))
{
$myrule['application_form'] = 'required_without:is_application_form';
}
return $myrule;
}
Run Code Online (Sandbox Code Playgroud)
我需要知道单击的按钮是Save还是Update,因为如果单击Save按钮我需要application_form文件字段,但是如果is_application_form hidden字段为空,我只需要application_form字段.
上面的设置适用于名称和年龄字段,但忽略IF条件内的代码.
我有一个使用此迁移代码创建的现有表:
Schema::create('mytable', function (Blueprint $table) {
$table->increments('id');
$table->double('mycolumn',8,2)->unsigned()->default(0);
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
然后我创建了另一个迁移文件,mycolumn
用下面的迁移文件来调整我的字段的值范围。
Schema::table('mytable', function (Blueprint $table) {
$table->double('mycolumn',15,2)->unsigned()->default(0)->change();
});
Run Code Online (Sandbox Code Playgroud)
但是我收到一个错误:
In DBALException.php line 283:
Unknown column type "double" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a li
st of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgott
en to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or …
Run Code Online (Sandbox Code Playgroud) 我的服务器计算机上有两个不同的 Laravel 应用程序。
他们位于:
D:/APPLICATION/application1
和
D:/APPLICATION/application2
以下是我的nginx.conf
内容:
server {
listen 80;
server_name localhost;
location / {
root "D:/APPLICATION/application1/public";
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri /index.php = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ^~ /application2 {
alias "D:/APPLICATION/application2/public";
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri /index.php = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include …
Run Code Online (Sandbox Code Playgroud) 我有这个数组:
array:2 [?
0 => array:3 [?
"time" => 7780
"name" => "John A. Doe"
"photo" => "johndoe.png"
]
1 => array:3 [?
"time" => 49800
"name" => "Jane B. Doe"
"photo" => "janedoe.png"
]
]
Run Code Online (Sandbox Code Playgroud)
该time
值是秒,我的问题是如何循环遍历数组,以便可以运行以下函数:
"time" => $this->secondsToHumanReadable(49800)
我的函数secondsToHumanReadable
已经过测试并且可以正常工作,我只希望它插入time
数组结果中的值。
更新:
所需的输出将是:
array:2 [?
0 => array:3 [?
"time" => '2 days, 1 hour, 3 minutes, 45 seconds'
"name" => "John A. Doe"
"photo" => "johndoe.png"
]
1 => array:3 [?
"time" => …
Run Code Online (Sandbox Code Playgroud)