Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

php - Lumen 5.6.4 get post route throwing MethodNotAllowedHttpException

whenever i try to access my url for a post in Lumen through the browser or postman i get the below error

Whoops, looks like something went wrong.
 MethodNotAllowedHttpException

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

see route code from web.php below

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

see code from 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);
    }

Can someone pls tell me what I am doing wrongly

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...