php - 重定向到不在laravel中重定向的路由
问题描述
我一直在使用Laravel-5.8.35
。GET
我正在通过表单调用请求。在我的路线上,我将form
操作重定向controller
到提交表单的位置,但通过不同的路线重定向,例如,
$router->get('/merchant/sd-refund', 'Reports\ReportController@refundSecurityDeposit');
而且,在我的refundSecurityDeposit
方法中,我调用了我的SohojSdRefundService
服务,
public function refundSecurityDeposit(Request $request)
{
// $userId, $reason, $sdAmount was fetched from the $request instance
$this->execRefundRequest($userId, $reason, $sdAmount);
}
public function execRefundRequest($userId, $reason, $sdAmount)
{
// here the API service request data was handled,
// and stored in $data instance
return SohojSdRefundService::callSdRefundApi($data);
}
当我的SohojSdRefundService
服务完成处理时,我想将路线重定向到另一条路线,因为,
class SohojSdRefundService
{
public function __construct()
{
}
public static function callSdRefundApi($requestData)
{
// call to other methods inside the class to handle the API response,
// and then return to the same route which isn't working
return redirect('/admin/merchant/list');
}
}
相应地,页面没有重定向到该路由,而是恰好仍然在最初提交的/merchant/sd-refund?...
位置。form
我重定向了另一个这样的服务,但它工作正常。任何人都可以建议我在这里实施错误吗?TIA。
解决方案
您需要在refundSecurityDeposit 函数中返回结果
public function refundSecurityDeposit(Request $request)
{
return $this->execRefundRequest($userId, $reason, $sdAmount);
}
推荐阅读
- android - 如何获取免费应用程序的免费天气数据?OpenWeatherMap 限制为 60 次调用/分钟
- php - Laravel 保存方法不更新记录
- terraform - Terraform Enterprise 模块文件位置错误
- vba - 如何使用outlook vba将html内容附加到word中
- python - 在 Sklearn 的 SVC 中,当标签大小很大时,为什么训练时间与最大迭代不严格线性?
- node.js - 使用 Mongo 聚合有条件地计算集合中的外部字段
- android - 如何禁用显示输入文本的灰色框
- javascript - D3 和 java 脚本
- python - 如何从 Python 中的集合列表创建集合?
- ios - 重绘时未清除 UIBezierPath