Undefined upon passing information from PHP to vue component

I am working on a wordpress plugin and i have a post type cause. I created some metabox in causes post type like minimum donation accepted and maximum donation accepted. Now i passed these values from PHP to take it from metaboxes and they are retrieving the values correctly. Here is my code for retrieving the values in form_components method

    /**
     * Form components.
     *
     * @return array
     */
    public function form_components()
    {
        $settings   = wpcm_get_settings();
        $currencies = $this->getCurrencies();
        $post_id = isset($_POST['id']) ? $_POST['id'] : '';
        $causes_settings = get_post_meta($post_id, 'causes_settings', true);

        // Unserialize the data to access individual settings
        $causes_data = maybe_unserialize($causes_settings);
        $show_min_max_donation = isset($causes_data['show_min_max_donation']) ? $causes_data['show_min_max_donation'] : 0;
        $amount_min_donation = isset($causes_data['min_donation_amount']) ? $causes_data['min_donation_amount'] : 0;
        $amount_max_donation = isset($causes_data['max_donation_amount']) ? $causes_data['max_donation_amount'] : 0;
        $post_type = $post_id ? get_post_type($post_id) : '';
        return array(
            'amounts'                => $this->getPredefinedAmount(),
            'currencies'             => $currencies,
            'base_currency'          => $settings->get('base_currency', 'USD'),
            'symbols'                => $this->currency_symbols($currencies),
            'symbol'                 => webinane_currency_symbol(),
            'show_currency_dropdown' => $post_type === 'membership' ? false : $settings->get('donation_multicurrency'), //false
            'show_amounts'           => $post_type === 'membership' ? false : $settings->get('donation_predefined_amounts'), //false
            'custom_amount'          => $post_type === 'membership' ? false : $settings->get('donation_custom_amount'), //false
            'show_recurring'         => $settings->get('donation_recurring_payments'),
            'show_custom_dropdown'   => $settings->get('enable_custom_dropdown'),
            'show_causes_dropdown'   => $settings->get('enable_funds_causes_dropdown'),
            'causes_list'            => $this->get_causes_list(),
            'donation_custom_dropdown' => $settings->get('donation_custom_dropdown'),
            'show_min_max_donation'  => $show_min_max_donation,
            'min_donation_amount'    => $amount_min_donation,
            'max_donation_amount'    => $amount_max_donation,
            'format_price'           => array(
                'position'  => $settings->get('currency_position', 'left'),
                'sep'       => $settings->get('thousand_saparator', ''), // Thousand Separator
                'd_sep'     => $settings->get('decimal_separator', '.'), // Decimal separator
                'd_point'   => $settings->get('number_decimals', 0) // Decimal numbers
            ),
            'strings'                => array(
                'how_much'        => esc_html__('How much would you like to donate?', 'lifeline-donation-pro'),
                'recurring'       => esc_html__('Recurring', 'lifeline-donation-pro'),
                'one_time'        => esc_html__('One Time', 'lifeline-donation-pro'),
                'donation_amount' => esc_html__('Enter the Amount you want to donate', 'lifeline-donation-pro'),
            ),
        );
        
    }

You can see the show_min_max_donation and min_donation_amount and max_donation_amount and thse all the retrieving the values correctly but when i pass them to vue component they are showing as undefined.

<template>
  <div>
    <div class="wpcm-custm-amt-before-title">
      <slot name="before_title"></slot>
      <h3 v-if="title" class="wpcm-custm-amt-title">{{ title }}</h3>
    </div>
    <div class="wpcm-custom-amt-box-container">
      <slot name="before_box"></slot>
      <div class="wpcm-custm-amt-box" v-if="custom_amount">
        <span v-if="symbol" class="wpcm-symbl-prefix">{{ getSymbol() }}</span>
        <input 
          :value="amount" 
          @input="handleInput" 
          @keypress="isNumber($event)" 
          :placeholder="strings ? strings.donation_amount : 'Enter The Amount You Want'"
        />
        <slot name="in_box"></slot>
      </div>
    </div>
    <slot></slot>
    <div v-if="errorMessage" class="error-message">{{ errorMessage }}</div>
  </div>
</template>

<script>
const { mapState, mapMutations } = window.Vuex;

export default {
  props: ['custom_amount', 'title', 'symbol', 'symbols', 'strings', 'display_amount'],
  data() {
    return {
      formData: window.donationFormData || {}, // Use embedded data or default to an empty object
      errorMessage: ''
    };
  },
  computed: {
    ...mapState(["amount", "currency", "recurring"]),
  },
  methods: {
    ...mapMutations(["setAmount"]),
    getSymbol() {
      return (this.symbols[this.currency] !== undefined) ? this.symbols[this.currency] : this.symbol;
    },
    isNumber(evt) {
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if ((charCode > 31 && (charCode < 48 || charCode > 57)) && charCode !== 46) {
        evt.preventDefault();
      } else {
        return true;
      }
    },
    handleInput(event) {
      const value = parseFloat(event.target.value);
      const minAmount = parseFloat(this.formData.min_donation_amount);
      const maxAmount = parseFloat(this.formData.max_donation_amount);

      if (this.formData.show_min_max_donation) {
        if (value < minAmount) {
          this.errorMessage = `The minimum donation amount is ${minAmount}.`;
          this.setAmount('');
        } else if (value > maxAmount) {
          this.errorMessage = `The maximum donation amount is ${maxAmount}.`;
          this.setAmount('');
        } else {
          this.errorMessage = '';
          this.setAmount(value);
        }
      } else {
        this.errorMessage = '';
        this.setAmount(value);
      }
    }
  }
}
</script>

<style>
.error-message {
  color: red;
  margin-top: 10px;
}
</style>

What i am trying to do it that validate the input field that if the minimum or maximum values is greater than or less than the values which we set through metabox then it should throw an error and user will not be able to go to next step by clicking on next button. also here is my next button vue component:

<template>
  <div>
    <el-button 
      @click="handleProceed" 
      v-if="step < config.steps"
      :disabled="campaign_ended"
    >
      {{ text || 'Proceed' }} 
    </el-button>
  </div>
</template>

<script>
const { mapState } = window.Vuex;

export default {
  props: {
    text: String,
    campaign_ended: {
      type: Boolean,
      default: false
    },
    error_message: {
      type: String,
      default: 'Target has been achieved'
    }
  },
  computed: {
    ...mapState(['step', 'config', 'validationError'])
  },
  methods: {
    handleProceed() {
      if (this.campaign_ended) {
        this.$message({
          message: this.error_message,
          type: 'error',
          duration: 5000,
          showClose: true
        });
      } else if (this.validationError) {
        this.$message({
          message: 'Please correct the errors before proceeding.',
          type: 'error',
          duration: 5000,
          showClose: true
        });
      } else {
        this.$store.commit('next');
      }
    }
  }
}
</script>

DateTime::createFromFormat(): Passing null to parameter #2 ($datetime) of type string is deprecated

Can Anyone help me. I have problem insert into database when using convert date format. I am using codeigniter 4 and mysql database. below is my code:

 foreach($worksheet_arr as $row){
                      // format date before convert = "1/15/2025"
                      $newDate =  DateTime::createFromFormat("m/d/Y", $date);
                      $date = $newDate->format("Y-m-d");
                      $this->db->query("INSERT IGNORE INTO efakturheaderone (BRANCH, REFERENCE, DATE) VALUES (?, ?, ?)", [$row[0], $row[1], $date]);
                    } 

but when I try dd($date); there is no problem.
Then when I code below, there is also no problem:

 foreach($worksheet_arr as $row){
                      $this->db->query("INSERT IGNORE INTO efakturheaderone (BRANCH, REFERENCE) VALUES (?, ?)", [$row[0], $row[1]);
                    } 

How can I ensure that the selected data is pre-selected in a relationship field?

I have created a vehicle add-on form using Filament. Adding and listing functionality is completed. However, when I click the edit button, the fields with related data are not pre-selected. How can I ensure that the related data is selected in the edit form? The form is created in the AddOn resource, and the AddOn model has a hasMany relationship with the AddOnVehicleType model

Select::make('vehicle_type')->multiple()
                    ->label('Vehicle Type')
                    ->options(function () {
                        return AppModelsVehicleType::pluck('name', 'id');
                    })
                    ->searchable()
                    ->placeholder('Vehicle Type')->required(),

//AddOn.php

    public function addOnVehicleType()
{
    return $this->hasMany(AddOnVehicleType::class);
}

codeigniter image not moving to folder: Undefined variable $file_name

VIEW:

<form method='post' action="<?php echo base_url('Reg_form/save')?>" enctype="multipart/form-data" name="reg_form">
  <div class="form-row">
    <div class="form-group col-md-3">
      <label for="">First name</label>
      <input type="text" class="form-control" id="fname" placeholder="First Name" name='Fname' required="">
    </div>
<div class="form-group col-md-3">
  <label for="">Last name</label>
  <input type="text" class="form-control" id="lname" placeholder="Last Name" name='Lname' required="">
</div>

<div class="form-group col-md-3">
  <label for="">Age</label>
  <input type="number" class="form-control" id="age" placeholder="age" name='Age' >
</div>
<div class="form-group col-md-2">
  <label for="">Image</label>
  <input type="file" class="btn btn-success form-control" name="img">
  
</div> 
<div class="form-group col-md-1">
  <label for=""> Save</label>
  <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Save</button>
</div>  
  </div>
    
  </form>

CONTROLLER:

function save() {

    $this->Reg_model->save();
    redirect(base_url('Reg_form/index'), 'refresh');
}

MODEL:

public function save() {

        // load base_url
        $this->load->helper('url');
        // Check form submit or not
                    
            $data = array();
                            
                // Set preference
                $config['upload_path'] = './assets/images'; 
                $config['allowed_types'] = 'jpg|jpeg|png|gif';
                $config['max_size']    = '100'; // max_size in kb
                $config['file_name'] = $_FILES['img']['name'];
                    
                //Load upload library
                $this->load->library('upload',$config);         
                
                // File upload
                if($this->upload->do_upload('img')){
                    // Get data about the file
                    $uploadData = $this->upload->data();
                    
                    $file_name = $uploadData['file_name'];
                    $data['response'] = 'successfully uploaded '.$filename;
                }else{
                    $data['response'] = 'failed';
                }
            
            $data = array(
            'Name' => $this->input->post('Fname'),
            'Fname' => $this->input->post('Lname'),
            'age' => $this->input->post('Age'),
            'image' => $file_name
        );

        $this->db->insert('student',$data);
        
        }

When I tried to upload the image it says undefined variable $file_name.

enter image description here this is the image of codeigniter showing the error

I am having a problem uploading an image file to a destination folder in my CodeIgniter application and it is not working at all. I have referred so many articles and downloaded some working one but they wouldn’t work once in my application

PHP: WordPress plugin – I want to create Google calendar event into specific shared google calendar

I wanted to create wordpress plugin for our music orchestra. In that wp plugin i wanted to be able to easily add event to google calendar. We use 1 shared google calendar. I have read some posts here about possibilities and ended up with this code handling google calendar:

 // Přidání funkce pro přidání události do Google Kalendáře
function add_event_to_google_calendar($event_details) {
    error_log_with_timestamp('add_event_to_google_calendar called');
    $credentials_path = plugin_dir_path(__FILE__) . 'credential.json'; // Ujistěte se, že cesta je správná
    if (!file_exists($credentials_path)) {
        error_log_with_timestamp('Credentials file not found: ' . $credentials_path);
        return [
            'error' => 'Credentials file not found.'
        ];
    }

    error_log_with_timestamp('Credentials file found: ' . $credentials_path);

    // Načtení přihlašovacích údajů
    $credentials = json_decode(file_get_contents($credentials_path), true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        error_log_with_timestamp('Error decoding credentials file: ' . json_last_error_msg());
        return [
            'error' => 'Error decoding credentials file.'
        ];
    }

    // Získání přístupového tokenu
    $token = get_google_access_token($credentials);
    if (isset($token['error'])) {
        error_log_with_timestamp('Error getting access token: ' . $token['error']);
        return [
            'error' => 'Error getting access token.test',//!!!!THIS LAST Error IF I USE POSTMAN!!!
            'details' => $token['error']
        ];
    }

    // Vytvoření události pomocí HTTP požadavku
    $calendarId = 'primary';
    $url = "https://www.googleapis.com/calendar/v3/calendars/$calendarId/events";
    $headers = [
        'Authorization: Bearer ' . $token['access_token'],
        'Content-Type: application/json'
    ];
    $response = http_post($url, json_encode($event_details), $headers);

    if ($response['status_code'] !== 200) {
        error_log_with_timestamp('Error adding event to Google Calendar: ' . $response['body']);
        return [
            'error' => 'Error adding event to Google Calendar.',
            'details' => $response['body']
        ];
    }

    $event = json_decode($response['body'], true);
    error_log_with_timestamp('Event added to Google Calendar: ' . $event['id']);
    return [
        'success' => true,
        'event_id' => $event['id']
    ];
}

But im stuck at point when i trie to create event ( via postman) and getting :

{
    "error": "Error getting access token.test"
}

I have service account for google api. i have credetial.json with all relevant data.. I dont have OAuth, but from what i read i dont need that for my usecase

space in url giving file not found error in browser

Physical folder having space: /about us/contactus.php

when we enter in browser https://www.example.com/about us/contactus.php
It will auto convert URL to https://www.example.com/about%20us/contactus.php

earlier it was working fine but after migrating to new server with same apache and php version,
it is giving error of file not found.

Rest of files working fine where there is no any space.

No any change in .htaccess hence require setting to do in either apache or php

It would great help if anyone can guide.

Multiple file upload via Github REST API

I use GrahamCampbell/Laravel-GitHub (which is actually a Laravel-wrapper for KnpLabs/php-github-api) to commit files from my application to Github via REST API.

With $client->api('repo')->contents()->create(...) and $client->api('repo')->contents()->update(...) I can modify individual files in my Github repo.

Now I would like to upload a whole directory (including files and subdirectories) to my repo, in one commit. I have tried the following sequence:

  • Create a tree with $client->api('gitData')->trees().
  • Commit the tree with $client->api('gitData')->commits().
  • Update heads/main with $client->api('gitData')->references().

But this only works as long as I upload my directory to the repo root directory. As soon as I try to commit to a Github subdirectory, everything in the root directory is overwritten. I’ve been experimenting for a while now, consulting google and perplexity, but I’m not getting anywhere.

Specifically, I would like to achieve the following two things:

  • Commit a directory structure to an (arbitrary) Github subdirectory
    • retaining the old files/directories in this directory structure
    • discarding the old files/directories only in the affected directory structure (i.e. all other Github directories should be retained)

This is basically similar to emptying folders and inserting content in the local file explorer, or inserting content and overwriting existing files.

Perhaps there is already a ready-made solution or PHP class for this, I would be very grateful for a reference. Otherwise, it would help me if someone could list the correct procedure for this:

  • Do I have to read and commit all existing trees with every commit (even to a deeper Github subdirectory)? I actually want the commit not to touch all existing files, but only the new or changed ones.
  • Which tree must my base_tree-SHA point to if I want to commit to my/sub/dir?

Many thanks in advance for your help

John Nazarov

triggering php page refresh when changes occur in DB

I have a php page (dashboard) that displays last 10 records (clocking punches) from mysql table. The clocking data is inserted by another .php file which deals with API request from clocking machine and runs INSERT sql query.

What is the best way to trigger the dashboard, to refresh the data once the INSERT query is run on the other page, so that the data displayed is up to date.

I would like to avoid constant page refreshes at set interval.

How to Resolve the Update function for single view page laravel -11 crud

I am trying to achive Single view page form.blade.php that deal with create edit and update function in laravel 11 .
Except the update are working

form.blade.php

    <x-app-layout>
    <x-create-form-layout 
        :action="$action" 
        :method="$method"
    >
        <x-slot name="title">
            {{ isset($category) ? 'Edit Category' : 'Create Category' }}
        </x-slot>

        <x-slot name="leftInputs">
        </x-slot>

        <x-slot name="rightInputs">
        </x-slot>

        <x-slot name="freeSlot">
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <!-- Left Column -->
                <div class="space-y-4">
                    <!-- Category -->
                    <div>
                        <label for="client" class="block text-gray-700 text-sm font-bold mb-2">Category</label>
                        <input 
                            type="text" 
                            name="name" 
                            id="category" 
                            required
                            class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500"
                            placeholder="Enter Category name"
                            value="{{ old('name', $category->name ?? '') }}"
                        >
                        @error('name')
                            <p class="text-red-500">{{ $message }}</p>
                        @enderror
                    </div>
                </div>

                <!-- Right Column -->
                <div class="space-y-4">
                    <!-- Code -->
                    <div>
                        <label for="gstin" class="block text-gray-700 text-sm font-bold mb-2">Code</label>
                        <input 
                            type="text" 
                            name="code" 
                            id="code" 
                            required
                            class="w-full border border-gray-300 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500"
                            placeholder="Enter Code"
                            value="{{ old('code', $category->code ?? '') }}"
                        >
                        @error('code')
                            <p class="text-red-500">{{ $message }}</p>
                        @enderror
                    </div>
                </div>
            </div>
        </x-slot>

        <!-- Buttons -->
        <x-slot name="buttons">
            <x-submit-button>{{ isset($category) ? 'Update' : 'Save' }}</x-submit-button>
            <x-list-button href="{{ route('categories.index') }}">List</x-list-button>
        </x-slot>
    </x-create-form-layout>
</x-app-layout>

create-form-layout.blade.php

    @props(['action', 'method' => 'POST', 'title', 'leftInputs', 'rightInputs', 'listHref' => '#','freeSlot'=>''])
<div class="max-w-6xl mx-auto mt-8">
    <form action="{{ $action }}" method="{{ $method }}"
        class="bg-white shadow-md rounded-lg p-6 space-y-8 min-h-[35rem]">
        @csrf
        @if (strtoupper($method) !== 'POST')
            {{-- <input type="hidden" name="_method" value="{{ strtoupper($method) }}"> --}}
            @method($method)
        @endif
        
        <h2 class="text-2xl font-semibold text-gray-700 text-center">{{ $title }}</h2>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <!-- Left Column -->
            <div class="space-y-4">
                <!-- Category -->
                {{ $leftInputs }}
            </div>

            <!-- Right Column -->
            <div class="space-y-4">
                <!-- Code -->
                {{ $rightInputs }}
            </div>
        </div>
        <div {{ $attributes->merge(['class' => ''])}}>
            {{ $freeSlot }}
        </div>

        <!-- Buttons -->
        <div class="flex justify-center space-x-4 mt-6">
            {{ $buttons }}
        </div>
    </form>
</div>

Controller

    class CategoryController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        $dataProvider = Category::all();
        return view('categories.index', compact('dataProvider'));
    }

    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        return view('categories.form', [
            'action' => route('categories.store'),
            'method' => 'POST',
            'category' => null, // No category data for create
        ]);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(StoreCategoryRequest $request)
    {
        Category::create($request->validated());
        return redirect()->route('categories.index')->with('success', 'Category created successfully.');
    }

    /**
     * Display the specified resource.
     */
    public function show(Category $category)
    {
        //    
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit($id)
    {
        $category = Category::findOrFail($id);
        $route = route('categories.update', $category->id);
        return view('categories.form', [
            'action' => $route,
            'method' => 'PUT',
            'category' => $category, // Pass existing category data for edit
        ]);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, Category $category)
    {
        logger('Update function reached', ['data' => $request->all()]);

        $category->update($request->only(['name', 'code']));
        return redirect()->route('categories.index')->with('success', 'Category updated successfully.');
    }
    
    public function destroy(Category $category)
    {
        $category->delete();
        return redirect()->route('categories.index')->with('success', 'Category deleted successfully.');
    }
}

when i submit the form in the edit state the page redirected to a blank white page with url http://localhost/my-app/public/categories/24?_token=kyfFfJDIG8CjfVKnvqKQKcldrH2d8752m8ZWMNyc&_method=PUT&name=Jumbo&code=n . and no leads to what happening . I tried logging the update function didn’t reach and no data related in the log .

@dump($action) result “http://localhost/my-app/public/categories/24” // resourcesviews/components/create-form-layout.blade.php

I can’t find the issue is

Psalm or PHPStan rules to enforce updates to DocBlocks?

Is there a way to tell Psalm or PHPStan to make sure that any updated methods also get updated DocBlocks?

This is a common challenge in software development teams. A DocBlock will get written during initial creation of a method. Then the method changes, and the DocBlock ends up being out of date and inaccurate.

If there’s an easy way to tell my CI pipeline (or even a git hook) that a DocBlock is in danger of being inaccurate, I would like to do that. If there’s not such a tool, I would like to build one as a small side project.

htaccess is not working on my website what i can do? [closed]

Here is my .htaccess for localhost:8080 which is working fine.

RewriteEngine on

# redirect non-www to www
# aktifkan aturan dibawah ini JIKA website kamu TIDAK diakses pada sub domain 
# aturan dibawah ini tujuannya untuk mencegah error 'Same-Origin'
# Sesuaikan/ganti tulisan 'domain' dan '.com' sesuai dengan nama domain kamu
# cara menonaktikannya adalah dengan menghilangkan karakter # didepan
# Namun jika website kamu diakses melalui sub domain, abaikan saja ini.

# Extra Security Headers
<IfModule mod_headers.c>
    Header set X-XSS-Protection "1; mode=block"
    Header always append X-Frame-Options DENY
    Header set X-Content-Type-Options nosniff
</IfModule>

#RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
#RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
#RewriteCond %{THE_REQUEST}  /index.php/?([^? ]*)
#RewriteRule ^ http://www.domain.com/%1 [L,R=301] 

# internally route to /index.php
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Options -Indexes

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

What can I do now? please help because before the website is normal but i do know why can do that.

Laravel cURL Error 7: Couldn’t Connect to Server on CentOS (Works on Local and CLI)

Tiêu đề:

Laravel cURL Error 7: Couldn’t Connect to Server on CentOS (Works on Local and CLI)


Nội dung:

I’m running a Laravel application on a CentOS server, and when making HTTP requests using Http::post or Http::get, I encounter the following error:

cURL error 7: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

Observations:

  1. Running the same API request using a direct cURL command in the terminal works perfectly.
  2. The same Laravel code runs without issues on my local development machine.
  3. Other network-dependent features in Laravel, like Slack notifications, also fail on the server.

What I’ve Tried:

  1. Verified cURL Installation:

    • php -m | grep curl confirms that cURL is installed and enabled in PHP.
  2. Checked cURL Version:

    curl -V
    

    Output:

    curl 7.x.x
    
  3. PHP Configuration:

    • Ensured extension=curl is enabled in /etc/php.ini.
    • Restarted php-fpm after any configuration changes.
  4. Verified OpenSSL:

    • Confirmed that openssl is installed and enabled in PHP.
  5. Firewall/DNS Checks:

    • No issues found; other outgoing connections (e.g., ping, curl from CLI) work fine.

Server Environment:

  • OS: CentOS 7
  • PHP: 8.x
  • Web Server: Nginx
  • Laravel: 11.x

Reproducible Laravel Code:

$response = Http::post('https://server.test/api/getStock', [
    'kioskToken' => 'RDZINRHC4JNG9VM5KQMI',
    'userToken' => 'K9QM4805P0O51A37NWWWVO9TN83SDEYOZ2AP',
]);

if ($response->failed()) {
    logger()->error('API request failed: ' . $response->body());
}

Questions:

  1. Why would cURL work via the terminal but fail in Laravel?
  2. Are there any specific Laravel or PHP-FPM configurations that could cause this issue on CentOS?
  3. Could there be a difference in the network environment between CLI and Laravel running via the web server?

Any help or insights would be greatly appreciated!

I try to deploy to another server, or install curl again

Add ACF Repeater Row Without Overwriting Existing Data

I’m working with WP All Import and Advanced Custom Fields (ACF). I need help ensuring that when importing data, a new row is added to a repeater field without overwriting existing rows.

Here’s the specific scenario:
I have a parent repeater field called sellers with the following subfields:

company (Merchant name)
price (Price)
link (Link)
During the import, I need to:

Check if the value of company matches the incoming {company_name[1]} from the record.
If it already exists, do nothing.
If it doesn’t exist, add a new row to the repeater field with the following values

bedrijf = {company_name[1]}
prijs = {search_price[1]}
link = {y_link[1]}

Currently, the import overwrites the entire repeater field, removing existing rows, which I need to avoid.

I tried:


add_action('pmxi_saved_post', function($post_id, $xml_data, $import_id) {
    if (get_post_type($post_id) !== 'product') return;

    $selector = 'sellers';
    $subfield1 = 'company';
    $subfield2 = 'prijs';
    $subfield3 = 'link';

    $merchant_name = $xml_data['company_name'][1] ?? '';
    $search_price = $xml_data['search_price'][1] ?? '';
    $aw_deep_link = $xml_data['company_name'][1] ?? '';

    if (empty($merchant_name)) return;

    $existing_rows = get_field($selector, $post_id) ?: [];
    foreach ($existing_rows as $row) {
        if ($row[$subfield1] === $merchant_name) return;
    }

    $existing_rows[] = [
        $subfield1 => $company_name,
        $subfield2 => $search_price,
        $subfield3 => $y_link,
    ];
    update_field($selector, $existing_rows, $post_id);
}, 10, 3);

But I am not able to get it to work.