vendredi 29 septembre 2023

Supervisor setup on laravel error can't find command 'php'

I am setup a Supervisor Configuration on my bitnami LAMP server but when I am ruining sudo supervisorctl error coming 'laravel_queue:laravel_queue_00 FATAL can't find command 'php''

My supervisor .conf file

'[program:laravel_queue]
process_name=%(program_name)s_%(process_num)02d
command=php /opt/bitnami/..../public/artisan queue:work --tries=1
directory=/opt/bitnami/...../public
startsecs = 0
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stderr_logfile=/opt/bitnami/..../public/storage/logs/laraqueue.err.log
stdout_logfile=/opt/bitnami/...../public/storage/logs/laraqueue.out.log
stderr_logfile_maxbytes=1MB
stdout_logfile_maxbytes=1MB'

As a newbies please suggest how to debug this issue.

when run php artisan queue:work on my web root found permission error so change the permission as per requirement & command running smoothy.



via Chebli Mohamed

How to connect laravel snowflake database [closed]

How to connect laravel snowflake database



via Chebli Mohamed

mercredi 27 septembre 2023

Laravel bosnadev/repository package issue when upgraded the laravel version from 5.8 to 10

I upgraded my laravel application that was previously using 5.8 to laravel 10. There is a following issue: Class "Bosnadev\Repositories\Eloquent\Repository" not found I try to install the package using composer require bosnadev/repositories. The following error message comes:

Problem 1 bosnadev/repositories[dev-master, dev-develop, 0.13, ..., 0.x-dev] require illuminate/support ^5.2 -> found illuminate/support[v5.2.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflict s with another require. bosnadev/repositories[0.1, ..., 0.12] require illuminate/support 5.* -> found illuminate/support[v5.0.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require. bosnadev/repositories 0.x-dev is an alias of bosnadev/repositories dev-master and thus requires it to be installed too. Root composer.json requires bosnadev/repositories * -> satisfiable by bosnadev/repositories[dev-master, dev-develop, 0.1, ..., 0.x-dev (alias of dev-master)].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require bosnadev/repositories:*" to figure out if any version is installable, or "composer require bosnadev/repos itories:^2.1" if you know which you need.

I tried to remove the problem but I get same error by making changes in composer.json file but still it does not allowed to install. So I need assistance in how to solve it.



via Chebli Mohamed

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);
    }
}


via Chebli Mohamed

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,



via Chebli Mohamed

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



via Chebli Mohamed

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']);


via Chebli Mohamed