流明5.6.4获取路由投掷方法MethodNotAllowedHttpException

时间:2018-08-18 01:49:34

标签: php lumen-5.4

每当我尝试通过浏览器或邮递员访问Lumen中的帖子的URL时,都会出现以下错误

Whoops, looks like something went wrong.
 MethodNotAllowedHttpException

in RoutesRequests.php 
at Application->handleDispatcherResponse(array(2, array('POST')))
in RoutesRequests.php 

从下面的web.php查看路由代码

 $router->post('gen','VoucherController@generateVoucherCode');

查看generateVoucherCode中的代码

class VoucherController extends Controller
{


    public function generateVoucherCode(Request $request){
// generate 16 digit random no.
    $random1 = rand(1111, 9999);
    $random2 = rand(1111, 9999);
    $random3 = rand(1111, 9999);
    $random4 = rand(1111, 9999);
    $voucher_code = ($random1."-".$random2."-".$random3."-".$random4);

    $today = date("Y-m-d");
    $use_once = "yes";
    $request->request->add( ['voucher_code' => $voucher_code,
        'use_once' => $use_once,
        'date_used' => $today,
        'date_created' => $today]);

        Voucher_code::create($request->all());

    return response()->json($voucher_code);
    }

有人可以告诉我我做错了什么吗

0 个答案:

没有答案
相关问题