我直截了当地讲到这里,我想知道是否有可能在Laravel的validation rule上传递一个参数。
这是我的密码:
我需要将$product->id传递给ProductUpdateRequest类。
我读过一些文章,但没有用,无法将一个参数传递给它。我的另一个解决方案是不使用验证规则类,并使用$request->validate[()]直接在控制器上进行验证。因为我可以访问控制器上的$product->id,所以我可以轻松地进行验证。但出于好奇,我有办法在$product->id上通过validation class吗?
控制器
public function u
我在EC2实例(类型为ubuntu16.04)上克隆了laravel项目,之后运行了composer install命令
我已经根据本地机器更改了/etc/nginx/site-available/default配置,这是
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/myproject/public;
charset utf-8;
# Add index.php to the list if you are using PH
因此,我的视图在卡片视图中显示产品,其中每个卡片都有一个add to cart按钮,该按钮通过AJAX JQuery提交表单。产品卡通过刀片循环在页面上填充。但是,它只允许我将第一个产品添加到购物车中。对于所有其他的错误,它会给出以下错误:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The POST method is not supported for this route. Supported methods: GET, HEAD.
我已经粘贴了我的刀片代码,这里包括jquery,所以阅读起来
我在用小提琴来测试我的要求。
我使用下面的reuest调用我的web方法,..it工作得很好。
http://localhost:50079/Import/Test/abc
Type :Get
web api method:
[ActionName("Test")]
public bool getconnection(string id)
{
return true;
}
如果我传递多个参数,我将得到错误:HTTP/1.1404未找到
我用的是:
http://localhost:50