mercredi 27 septembre 2023

Why do Refresh Token expires after every 7 days ? Does it affects the file upload on production

I implemented a Laravel web-app with Google Drive's API used for storage. I used this tutorial https://gist.github.com/sergomet/f234cc7a8351352170eb547cccd65011. When i am trying to upload file on google drive i am facing the issue of refresh token expiration every 7 days .So if refresh token is being expired it affects the file upload on google drive I need to deploy on production.

I tried with this code, moral of the story is that whether access token expires or refresh token expires , while file upload flow should not give error

public function uploadFile(UploadedFile $uploadedFile, string $file,string $folderId)
    {
        $client = new Google_Client();
        $client->setClientId(env('GOOGLE_DRIVE_CLIENT_ID'));
       $client->setClientSecret(env('GOOGLE_DRIVE_CLIENT_SECRET'));
       $client->refreshToken(env('GOOGLE_DRIVE_REFRESH_TOKEN'));
        $this->refreshTokenIfNeeded($client);
        $fileName = $uploadedFile->getClientOriginalName();
        $mimeType = $uploadedFile->getClientMimeType();
        $fileContent = file_get_contents($uploadedFile);
        $fileMetadata = new Google_Service_Drive_DriveFile(array(
            'name' => $fileName,
            'parents' => array($folderId)
        ));
        //file upload code
}
 public function refreshTokenIfNeeded(Google_Client $client): void
    {

        if ($client->isAccessTokenExpired()) {
          $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
           $newAccessToken = $client->getAccessToken();
            $this->saveAccessTokenToStorage($newAccessToken);
    }
 else {
            $oldAccessToken = $client->getAccessToken();
            $this->saveAccessTokenToStorage($oldAccessToken);
        }
    }

    public function saveAccessTokenToStorage($newAccessToken): void
   {
       $accessTokenJson = json_encode($newAccessToken);
        $credentialsFilePath = env('GOOGLE_CREDENTIALS_FILE');
       Storage::put("$credentialsFilePath", $accessTokenJson);
    }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/dVLKeEx
via IFTTT

mardi 26 septembre 2023

Vue.js codes are not working in Production

I'm working on a client webapp which is on Laravel 5.6 with Vue.js (2.5.7). I'm new to Vue.js. Today, I updated few of my Vue.js codes and pushed to production. It is working on local but is not working on Production, although I can clearly see the codes there.

Can an Vue expert please suggest what could be the reason?

Thanks in advance,



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/jpSH0n9
via IFTTT

samedi 23 septembre 2023

ErrorException (E_NOTICE) Undefined index: model Matt excel laravel

I am trying add data to database via excel file but it was working for a moment then it throws undefined index error

import function

 public function importExcel(Request $request)
    {

        if ($request->hasFile('file')) {

            Excel::load($request->file('file')->getRealPath(),  function ($reader) {
                foreach ($reader->toArray() as $row) {
                  
                    $data['date'] = $row['date'];
                    $data['chassis_no'] = $row['chassis_no'];
                    $data['model'] = $row['model'];
                    $data['color'] = $row['color'];
                    $data['supervisor'] = $row['supervisor'];
                    $data['technician'] = $row['technician'];
                    $data['job_card_type'] = $row['job_card_type'];
                    $data['total_amount'] = $row['total_amount'];
                    $data['remark'] = $row['remark'];



                    $jobcard = new Jobcard();

                    $jobcard->created_at =Carbon::parse($row['date']);
                    $jobcard->chasis_no = $row['chassis_no'];
                    $jobcard->model = $row['model'];
                    $jobcard->color = $row['color'];
                    $jobcard->supervisor = $row['supervisor'];
                    $jobcard->technician =  $row['technician'];
                    $jobcard->jobcard_type =$row['job_card_type'];
                    $jobcard->total_amount = $row['total_amount'];
                    $jobcard->created_id = auth()->user()->id;
                    $jobcard->remark = $row['remark'];


                    $jobcard->save();


                }
            });
            return back()->with('success', 'Your File Is Successfully Uploaded To Database!');
        }
        return back()->with('success', 'File Doesnt Uploaded!');
    }

View

 <div class="col-md-5">
    <div class="form-group">
        <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
            
            <div class="input-group">
                <div class="custom-file">
                  <input type="file" class="custom-file-input" name="file">
                  <label class="custom-file-label" for="inputGroupFile04">Choose file</label>
                </div>

              </div>
              <br><br>
              <div class="col-9">
                <button type="submit" class="btn btn-info waves-effect waves-light w-lg rbutton">
                    Upload
                </button>
            </div>

           </form>
    </div>
</div>

Excel File enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/U1MbASv
via IFTTT

vendredi 22 septembre 2023

The POST method is not supported for this route Laravel

Payment success redirect working but if the payment has been cancelled, it does not redirect. How can i fix this? Payment success redirect working but if the payment has been cancelled, it does not redirect. How can i fix this? Error: The POST method is not supported for this route. Supported methods: GET, HEAD. Error İmage: enter image description here

Paymax:

else if($payment_method == "paymax"){
        $sid = 1;

        $settings = Settings::editGeneral($sid);

        $paymaxHelper = new Paymax(
                                    $settings->paymax_username,
                                    $settings->paymax_password,
                                    $settings->paymax_shopcode,
                                    $settings->paymax_hash
                                );

        $site_currency = ( $site_currency == "USD" ? "USD" : $site_currency);
        $order_data = array(
            'productName' => $item_names_data,
            'productData' => array(
                array(
                    'productName'=>$item_names_data,
                    'productPrice'=>$final_amount,
                    'productType'=>'DIJITAL_URUN',
                ),
            ),
            'productType' => 'DIJITAL_URUN',
            'productsTotalPrice' => $final_amount,
            'orderPrice' => $final_amount,
            'currency' => $site_currency,
            'orderId' => $purchase_token,
            'locale' => 'tr',
            'conversationId' => '',
            'buyerName' => $order_firstname,
            'buyerSurName' => $order_firstname,
            'buyerGsmNo' => '05xxXXXxxXX',
            'buyerIp' => $_SERVER['REMOTE_ADDR'],
            'buyerMail' => $order_email,
            'buyerAdress' => '',
            'buyerCountry' => '',
            'buyerCity' => '',
            'buyerDistrict' => '',
            'callbackOkUrl' => $website_url.'/paymax-success/'.$purchase_token,
            'callbackFailUrl' => $website_url.'/paymax-failure/'.$purchase_token
        );
        /*Sipariş Bilgilerinizi link oluşturmak için sınıfa gönderin*/
        $request = $paymaxHelper->create_payment_link($order_data);
                                
        if($request['status']=='success' && isset($request['payment_page_url']))
        {
            $odeme_link = $request['payment_page_url'];
            return redirect($odeme_link);
        }
        
      

   return view('deposit')->with($totaldata);


}

    public function paymax_callback(Request $request){
    $ord_token = $request->orderId;
        
    $itemOrder = DB::table('item_order')->where('purchase_token', $ord_token)->first();
    if($itemOrder){
        $response = $this->paymax_order_success($ord_token, $request);
    }else{
        $response = $this->deposit_paymax_success($ord_token, $request);
    }
    if($response["status"]){
        echo 'OK';
        exit();
    }
    echo $response["message"];
    exit();
}

Failure:

    public function paymax_failure($ord_token, Request $request){
    return view('cancel');
}

Routes:

Route::get('/paymax-success/{ord_token}', ['as' => 'paymax-success','uses'=>'ItemController@paymax_success']);

Route::get('/paymax-failure/{ord_token}', ['as' => 'paymax-failure','uses'=>'ItemController@paymax_failure']);

Route::post('/paymax-callback', ['as' => 'paymax-callback','uses'=>'ItemController@paymax_callback']);


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/0Yz8dT2
via IFTTT

mercredi 20 septembre 2023

Filament decrypt data

How I have encrypted data in Laravel filament before storing it in the database and then I can't decrypt it before displaying in Laravel filament. How can I achieve this in Laravel filament?

Fields I want to encrypt Name, Email.

I am not able to achieve it. Please help me in it.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/CigK7Yf
via IFTTT

mardi 19 septembre 2023

Getting ModSecurity: Access denied with code 44 on Laravel Form Submit

I am trying to submit a form in Laravel but getting this error:

ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_STRICT_ERROR" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "31"] [id "200002"] [msg "Multipart request body failed strict validation: PE 0, BQ 0, BW 0, DB 0, DA 0, HF 0, LF 0, SM 0, IQ 1, IP 0, IH 0, FL 0"]

No file upload nothing, it's just simple form submit.

I tried without special chars in form data but still getting this error.

Any suggestions?

I tried submitting data w/o special chars I tried (earlier) uploading a file w/o special chars in the file name



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/qkSIF3C
via IFTTT

mercredi 13 septembre 2023

In this code i can't run operation to insert database in laravel , may anyone askme where is wrong in my code

the controller

public function storeToDatabase(Request $request)
    {
        $params = $request->except('_token');
    
        $user_id = auth()->user()->id;
        $product_id = $params['product_id'];
        $price = $params['price'];
        $quantity = $params['quantity'];
        $name_product = $params['name_product'];
        $total_price = $params['total_price'];
    
        Cart::create([
            'user_id' => $user_id,
            'product_id' => $product_id,
            'price' => $price,
            'quantity' => $quantity,
            'name_product' => $name_product,
            'total_price' => $total_price,
        ]);
    
        \Session::flash('success', 'Product ' . $name_product . ' berhasil dimasukan keranjang.');
    
        return redirect('/carts');
    }

Just eror and no console in error, idont use dd in console and then i dont know what wrong in my code



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/0T6etgj
via IFTTT