dqq46733 2016-04-02 15:22
浏览 19
已采纳

结合Laravel中的表单请求

I have two requests that validate forms:

  • StoreProductRequest (validates a newly created product)
  • StoreProductBuildRequest (validates the components within the product)

In the 'edit' view, this functionality is combined into one form.

What is the best way to run through both form requests when submitting this form? I would rather avoid creating a new request (StoreProductAndBuildRequest?) as this isn't very DRY.

Related, but I wonder if there's a cleaner / more Laravel way: How to merge two Request in Laravel

  • 写回答

1条回答 默认 最新

  • dswmmvrg40957 2016-04-02 15:47
    关注

    Have you tried injecting both form requests?

    public function update(StoreProductRequest $requestOne, StoreProductBuildRequest $requestTwo)
    {
        // do something
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!