mercredi 9 octobre 2019

Laravel 5.4 $request->all()/$request->input('name') returns null

Basically, while making a GET Api, ever since I added a manual authorization method into my project, my $request->all() and the such have been returning null to me. What is wrong here? I'm not sure if the issue lies in my Codes or in Postman. Would really appreciate some help here.

API function;

public function checkMoq(Request $request, $id){
    $auth_token = \Config::get('constants.API_AUTH');
    $access_token = $request->header('Authorization');



    if($access_token == $auth_token)
    {
        $input = $request->input('qty');
    dd($input);
        $qty = $input['qty'];
        $product_id = $id;
        $product = \App\Product::find($id);
        $achievedMinimumOrderQuantity = $product->achievedMinimumOrderQuantity($qty);
        dd($achievedMinimumOrderQuantity);

    }else{
        return "Invalid Authorization";
    }

}

api.php route;

Route::get('checkmoq/{id}', [
    'uses' => 'ApiGetController@checkMoq'
]);

Postman params;

Header: Authorization, Value: "testapi"
form-data: key: qty, value: 1

In the end, when i dd($input), i get an empty array.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire