小编kap*_*tan的帖子

laravel Form Request =如果单击了按钮

因为我有保存和更新按钮,所以我需要知道在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条件内的代码.

php laravel

4
推荐指数
1
解决办法
3400
查看次数

迁移 - 无法更改 Double 数据类型值

我有一个使用此迁移代码创建的现有表:

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

2
推荐指数
2
解决办法
3620
查看次数

使用 Nginx 的多个 Laravel 应用程序 - Windows

我的服务器计算机上有两个不同的 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)

windows nginx laravel

1
推荐指数
1
解决办法
3862
查看次数

PHP-对数组值执行函数

我有这个数组:

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)

php laravel

0
推荐指数
1
解决办法
58
查看次数

标签 统计

laravel ×4

php ×2

nginx ×1

windows ×1