dimanche 25 février 2018

Send request parameter from console commands laravel

How can I send request via console commands in laravel 5.1 ? I need to pass API request to controller in same folder project, my first attempt is using guzzle :

$gClient =  new \GuzzleHttp\Client(['base_uri' => env('URL_AUTO_CONFIRM_PAYMENT')]);

$res = $gClient->post('api/payment/inquiries',
                            [
                                'headers'=> [
                                    'Content-Type' => 'application/json',
                                    'Accept' => 'application/json'
                                ],
                                'json'=>[
                                    'payment_method' => 'transfer',
                                    'payment_channel' => 'bca',
                                    'account_number' => $row->parameter['accountNo'],
                                    'invoice_id' => $row->parameter['paymentInvoice'],
                                    'amount' => (int)$row->parameter['totalCommission'],
                                    'currency_code' => 'IDR',
                                    'description' => 'Testing'
                                ],
                                'http_errors' => false
                            ]
                    );

but I think its not good because in same folder project, which can I call controller directly, but the problem is, my controller has been set to only receive $request not param (my_controller(Request $request)). So, how can I handle this ? It is ok using guzzle ? Or should I use another alternative ? Any advice will appreciate. Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Fzxccc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire