How to fetch the earlier record from mysql query compare with date?

Hope you all are doing well. Actually i am struggling with a minor issue. I am trying to fetch the closest record of if date not matched in database. But somehow it is not working or you can say giving me the wrong information.

After research of 2-3 days. My Jira ticket is move to done and get back to me again. So i need your help to fix this problem. Below is my code that you can check and help me to find the bug.

        $atg = @DB::table('mc_atginfo')
            ->where('SiteId', Input::get('siteId'))
            ->where('TankId', Input::get('tankId'))
            ->orderByRaw('ABS(TIMESTAMPDIFF(SECOND, ATGDateTime,?))', [$inputDateTimeFormatted])
            ->orderBy('ATGDateTime', 'desc')
            ->first();
        return Response::json($atg);
    }

Any solution appreciated!

Woocommerce Customers API Laravel

I’ve been trying to synchronize my WooCommerce customers with Laravel using this package, aiming to ensure seamless integration of products, orders, and customer data.

composer require automattic/woocommerce

The package functions smoothly when retrieving Products or Orders.

Here is the sample code.

This code is returning an empty array from WooCommerce. The problem seems to be specific to customers, as it’s not retrieving any data; only an empty array is returned.

$since_id = 0;
$url            =   $this->store['store_url'];
$consumer_key   =   $this->store['consumer_key'];
$consumer_secret=   $this->store['consumer_secret'];
$options        =   [ 'wp_api' => true, 'version' => 'wc/v3' ];
$woocommerce    =   new Client($url, $consumer_key, $consumer_secret, $options);

$page = 1;
$per_page = 100; // Set a reasonable limit to avoid overloading
$limit = 10000;
$all_customers = [];
do {
    $args = [
        'per_page' => $per_page,
        'page' => $page,
    ];
    $customers = $woocommerce->get('customers', $args);
    $all_customers = array_merge($all_customers, $customers);
    // Check if there are more orders:
    $page++;
} while (count($customers) >= $per_page);

Here are the responses I’m receiving from WooCommerce:
enter image description here

My php code is working earlier but now it wont

i am creating an login form and earlier it worked, it did login but now it wont it is just hard stuck here in invalid password even if i put a correct password

i did try using ai or watching yt vids but nothing seems to help, it also wont even show the scripts code. please help this is my first time working in this so bear wth me

<?php 
session_start(); 
$host = 'localhost';
$dbusername = 'root';
$dbpassword = '';
$dbname = 'enrollment_form';

// Connect to the database
$conn = mysqli_connect($host, $dbusername, $dbpassword, $dbname);

// Check for connection errors
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if (isset($_POST['email']) && isset($_POST['password'])) {

    function validate($data){
       $data = trim($data);
       $data = stripslashes($data);
       $data = htmlspecialchars($data);
       return $data;
    }

    $email = validate($_POST['email']);
    $password = validate($_POST['password']);

    if (empty($email)) {
        header("Location: login.php?error=email is required");
        exit();
    }else if(empty($password)){
        header("Location: login.php?error=Password is required");
        exit();
    }else{
        $sql = "SELECT * FROM registration WHERE email='$email' AND password='$password'";

        $result = mysqli_query($conn, $sql);

        if (mysqli_num_rows($result) === 1) {
            $row = mysqli_fetch_assoc($result);
            if ($row['user_name'] === $email && $row['password'] === $password) {
                $_SESSION['user_name'] = $row['user_name'];
                $_SESSION['name'] = $row['name'];
                $_SESSION['id'] = $row['id'];
                header("Location: home.php");
                exit();
            }else{
                header("Location: login.php?error=Incorect email or password");
                exit();
            }
        }else{
            header("Location: login.php?error=Incorect email or password");
            exit();
        }
   }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Login</title>
  <link rel="stylesheet" href="new.css">
</head>
<body>
<div class="login-container">
  <header>
      <a href="index.html">
         <h2 class="logo"></h2>
     </a>
       <nav class="navigation">
          <a href="home.php">Home</a>
          <a href="enrollment.php">Enroll</a>
          <a href="contact.php">Contact Us</a>
          <button class="btnLogin-popup">Login</button>
       </nav>
   </header>
   <div class="wrapper">
      <span class="icon-close">
         <ion-icon name="close-outline" onclick="redirectHomepage()"></ion-icon>
      </span>
      <div class="form-box Login">
         <h2>Login</h2>
         <form method="POST">
            <div class="input-box">
               <label for="email">Email</label>
               <ion-icon name="mail-outline"></ion-icon>
               <input type="email" id="email" name="email" placeholder="Email" required>
            </div>
            <div class="input-box">
               <label for="password">Password</label>
               <ion-icon name="lock-closed-outline" class="icon"></ion-icon>
               <input type="password" id="password" name="password" placeholder="Password" required>
            </div>
            <button type="submit" class="btn" name="submit">Login</button>
            <div class="register-link">
               <p>Don't have an account</p>
               <a href="registration.php">Create an Account</a>
            </div>
         </form>
      </div>
   </div>
</div>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script src="script.js"></script>
</body>
</html>

How can I resolve the Moodle 4.3 installation error related to the PHP configuration and dynamic extensions?

After completing the installation on the web browser right before I can set up my Moodle, I receive this error message: Installation must be finished from the original IP address, sorry. and if I press continue I receive another error message: Cannot initialize PHP session. Please verify that your browser accepts cookies.

To resolve the first message, I tried to do the installation all on one aws server without stopping it so as to have the same Ip and to resolve the second one I allowed all cookies to work on my browser please help.

PHP OR .NET Developer [closed]

I started learning php and mysql for my graduationproject and now I am good with them ,not experience but good
Now I am torn between keep learning php track and learn laravel OR
Learning .NET Track for my career .
I will be grateful for advice

I tried to start learning Laravel, but there are some who tell me that .NET is the future and the most popular currently.

Larastan doesn’t resolve aliase of facades

I’m using larastan on a Laravel project.
When I use a facade like ¥Auth::check() like code below, larastan can’t resolve the return type of this method.

function index()
{
  if(¥Auth::check()) { // as mixed
    // ...
  }
}

I know it’s resolved by adding a use operator with IlluminateSupportFacadesAuth; and using Auth::check() instead.

use IlluminateSupportFacadesAuth;

function index()
{
  if(Auth::check()) { // as bool
    // ...
  }
}

Is it not recommended to use alias of facades with larastan?
Let me know the best practice if there are some way to use facade alias with larastan.

Why Guzzle onrejected function in promise-then still throw an exception?

I found that the $promise->wait() function will throw an exception and I must use try-catch to handle exception again.

$promise = $this->client->sendAsync($request);
$promise->then(
    function ($response) use (...){
        //do something
    },
    function ($exception) {
        $this->logger->error("Failed " . $exception->getMessage());
    }
);
try{
    $promise->wait(true);
}catch(Exception $exception){
    $this->logger->error("Failed " . $exception->getMessage());
}

The error info will be recorded by logger twice. Is there any method that the exception can be handled in onrejected fuction? Or any better way to handle such exception?

Here’s my error:
PHP Fatal error: Uncaught GuzzleHttpExceptionClientException: Client error:…

Thank you very much for your help.

I have tried this

$promise->then(
//...
)->then(
//...
);

but not work.

How to save registered user in database with yii2?

I try to save a registerd user in the database with an api call.

So I have an model User.php:

<?php

namespace appmodels;
use Yii;
use yiibaseNotSupportedException;
use yiibehaviorsTimestampBehavior;
use yiidbActiveRecord;
use yiiwebIdentityInterface;


class User extends yiidbActiveRecord implements IdentityInterface
{

    const STATUS_DELETED = 0;
    const STATUS_INACTIVE = 9;
    const STATUS_ACTIVE = 10;
 

 
    public function behaviors()
    {
        return [
            TimestampBehavior::class,
        ];
    }

    public static function tableName()
    {
        return '{{%user}}';
    }


    public function rules()
    {
        return [
            ['status', 'default', 'value' => self::STATUS_ACTIVE],
            ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_INACTIVE, self::STATUS_DELETED]],
        ];
    }

}

and an controller UserController.php:

<?php
// phpcs:ignoreFile

namespace appmodulesv1controllers;
use Yii;
use appmodelsUser;
use yiirestActiveController;
use yiiwebResponse;

class UserController extends ActiveController
{
    public $modelClass = 'appmodelsUser';


    public function actionSignup()
    {
        $user = new User();
        $user->load(Yii::$app->getRequest()->getBodyParams(), '');
        
        if ($user->save()) {
            Yii::$app->response->statusCode = 201;
            return ['status' => 'success', 'data' => 'User registered successfully'];
        } else {
            Yii::$app->response->statusCode = 400;
            return ['status' => 'error', 'data' => $user->errors];
        }
    }

and urlManager in web.php looks:

 'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' =>  ['class' => 'yiirestUrlRule', 'controller' => 'v1/user', 'POST' => 'v1/user/signup'],
            
        ]

and databse schema looks:

$this->createTable('{{%user}}', [
            'id' => $this->primaryKey(),
            'username' => $this->string()->notNull()->unique(),
            'auth_key' => $this->string(32)->notNull(),
            'verification_token'=> $this->string()->defaultValue(null),
            'password_hash' => $this->string()->notNull(),
            'password_reset_token' => $this->string()->unique(),
            'email' => $this->string()->notNull()->unique(),
            'status' => $this->smallInteger()->notNull()->defaultValue(10),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
        ]);

But if I try to call the api call in postman:

http://localhost:8080/v1/user/signup with json object:

{
    "username": "example_user",
    "password_hash": "example_password",
    "email": "[email protected]" 
}

I get this error:

 "name": "Integrity constraint violation",
    "message": "SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "username" of relation "user" violates not-null constraintnDETAIL:  Failing row contains (3, null, null, null, null, null, 10, 1710925298, 1710925298, null).nThe SQL being executed was: INSERT INTO "user" ("status", "created_at", "updated_at") VALUES (10, 1710925298, 1710925298) RETURNING "id"",

Question: how to resolve this error?

cakephp bake console error Exception: SQLSTATE[HY000] [2002] No such file or directory in

I’m trying to follow the CakePHP tutorial for tags and users here.: https://book.cakephp.org/3/en/tutorials-and-examples/cms/tags-and-users.html

However, I keep encountering this error for bin/cake bake model users and bin/cake bake template users.

bin/cake bake controller users works fine.

I tried changing the database host to ‘host’ => ‘127.0.0.1’ but it still shows the same error.

Does anyone know how to solve this? I’m using CakePHP in vagrant environment on Mac OS. Thank you!

This is what the error says for both model users and template users command.

Exception: SQLSTATE[HY000] [2002] No such file or directory in [/home/vagrant/app/vendor/cakephp/cakephp/src/Database/Driver.php, line 93]
2024-03-20 09:01:03 Error: [PDOException] SQLSTATE[HY000] [2002] No such file or directory in /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Driver.php on line 93
Stack Trace:
#0 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Driver.php(93): PDO->__construct('mysql:host=loca...', 'my_app', 'secret', Array)
#1 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Driver/Mysql.php(105): CakeDatabaseDriver->_connect('mysql:host=loca...', Array)
#2 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Schema/BaseSchema.php(44): CakeDatabaseDriverMysql->connect()
#3 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Dialect/MysqlDialectTrait.php(62): CakeDatabaseSchemaBaseSchema->__construct(Object(CakeDatabaseDriverMysql))
#4 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Schema/Collection.php(51): CakeDatabaseDriverMysql->schemaDialect()
#5 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(41): CakeDatabaseSchemaCollection->__construct(Object(CakeDatabaseConnection))
#6 /home/vagrant/app/vendor/cakephp/cakephp/src/Database/Connection.php(399): CakeDatabaseSchemaCachedCollection->__construct(Object(CakeDatabaseConnection), true)
#7 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(1096): CakeDatabaseConnection->getSchemaCollection()
#8 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(1050): BakeShellTaskModelTask->_getAllTables()
#9 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(213): BakeShellTaskModelTask->listAll()
#10 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(131): BakeShellTaskModelTask->getAssociations(Object(CakeORMTable))
#11 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(114): BakeShellTaskModelTask->getTableContext(Object(CakeORMTable), 'users', 'Users')
#12 /home/vagrant/app/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(101): BakeShellTaskModelTask->bake('Users')
#13 /home/vagrant/app/vendor/cakephp/cakephp/src/Console/Shell.php(531): BakeShellTaskModelTask->main('users')
#14 /home/vagrant/app/vendor/cakephp/cakephp/src/Console/Shell.php(524): CakeConsoleShell->runCommand(Array, false, Array)
#15 /home/vagrant/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(384): CakeConsoleShell->runCommand(Array, true)
#16 /home/vagrant/app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(162): CakeConsoleCommandRunner->runShell(Object(BakeShellBakeShell), Array)
#17 /home/vagrant/app/bin/cake.php(12): CakeConsoleCommandRunner->run(Array)
#18 {main}

Any help would be appreciated. Thank you so much.

Is this bayesian average calculation right?

We have been using a bayesian average on a website of ours for a couple of years now and it seems to have working great but when using the same formula with other (good) data on another website the output was a bit disturbing.

We use this PHP code:

<?php
$avg_num_reviews = 6264.3636363636;
$avg_rating = 4.527272727272727;
$this_num_review = 4;
$this_average_rating = 4;
$bayesian_average = (($avg_num_reviews * $avg_rating) + ($this_num_reviews * $this_average_rating)) / ($avg_num_reviews + $this_num_reviews);
echo $bayesian_average;
?>

This normaly is filled in dynamicly but to give you an idea we will put in the data manualy.

So this data:

$avg_num_reviews = 6264.3636363636;
$avg_rating = 4.527272727272727;

is correct.

If we then calculate the Bayesian average, then in my opinion something is going wrong. It would help us enormously if someone could say something meaningful about this.

$this_num_reviews = total number over reviews for this company;
$this_average_rating = the average rating of this company;

Now we get to the weird part.:

Company A

$avg_num_reviews = 6264.3636363636;
$avg_rating = 4.527272727272727;
$this_num_review = 4;
$this_average_rating = 4;
$bayesian_average = (($avg_num_reviews * $avg_rating) + ($this_num_reviews * $this_average_rating)) / ($avg_num_reviews + $this_num_reviews);

$bayesian_average = 4.5269362613254;

Company B

$avg_num_reviews = 6264.3636363636;
$avg_rating = 4.527272727272727;
$this_num_review = 111;
$this_average_rating = 4.2;
$bayesian_average = (($avg_num_reviews * $avg_rating) + ($this_num_reviews * $this_average_rating)) / ($avg_num_reviews + $this_num_reviews);

$bayesian_average = 4.5215746565744;

Company C

$avg_num_reviews = 6264.3636363636;
$avg_rating = 4.527272727272727;
$this_num_review = 15468;
$this_average_rating = 4.4;
$bayesian_average = (($avg_num_reviews * $avg_rating) + ($this_num_reviews * $this_average_rating)) / ($avg_num_reviews + $this_num_reviews);

$bayesian_average = 4.4366864211353;

If we would sort this based on the bayesian average it will be like this:

  1. Company A
  2. Company B
  3. Company C

But how can it happen that a company (Company C) with 15468 reviews and an average of 4.4 has a lower Bayesian average than a company (Company A) with 4 reviews and an average of 4?

The Bayesian average should ensure that these kinds of things are prevented.

The logical sequence should be as follows:

  1. Company C
  2. Company B
  3. Company A

Can someone explain to me why this happens and whether there might be something wrong in the formula?

Am I missing something or should I use a different formula to do this better?

If anyone can say something meaningful about this, I would be very grateful to that person because I am a bit off track at the moment.

I am making a webshop for a school project, we need to have a shopping cart with updating items in the shopping cart, I am a beginner

For a school project we need to make a webshop with shopping cart and database, We are selling games and we have found out how to get a button and send the product to the shopping cart and increasing the number of products with + or decreasing with -. But if we increase the product by pressing +, and go to another tabblad ( for example back to the products tabblad), then it isn’t saved so it is back to 1 product in the shopping cart. i think this might be a problem with the sessions. Can somebody help me please?

I’ve tried it with chatgpt, but it doesn’t work. (Im working with codeanywhere btw)

WordPress Plugin update_check not working properly

I am facing an issue of update now button not showing up even if there is an update for a plugin. The following is the method that checks the updates for the plugin

public function check_update( $_transient_data ) {
        
        global $pagenow;

        if ( ! is_object( $_transient_data ) ) {
            $_transient_data = new stdClass;
            
        }

        if ( 'plugins.php' == $pagenow && is_multisite() ) {
            return $_transient_data;
        }
        
        if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
            return $_transient_data;
        }

        $version_info = $this->get_cached_version_info();

        if ( false === $version_info ) {
            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
            error_log('version info from api'.wp_json_encode($version_info));
            $this->set_version_info_cache( $version_info );

        }

        if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {

            if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {

                $_transient_data->response[ $this->name ] = $version_info;

            }

            $_transient_data->last_checked           = time();
            $_transient_data->checked[ $this->name ] = $this->version;

        }

        return $_transient_data;
    }

This is the method that gets the info related to version info in the cache:

public function get_cached_version_info( $cache_key = '' ) {

        if( empty( $cache_key ) ) {
            $cache_key = $this->cache_key;
        }

        $cache = get_option( $cache_key );

        if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
            return false; // Cache is expired
        }

        return json_decode( $cache['value'] );

    }

And this is the method which sets the version info in the cache:

public function set_version_info_cache( $value = '', $cache_key = '' ) {

        if( empty( $cache_key ) ) {
            $cache_key = $this->cache_key;
        }

        $data = array(
            'timeout' => strtotime( '+3 hours', time() ),
            'value'   => json_encode( $value )
        );

        update_option( $cache_key, $data, 'no' );

    }

When I remove/delete the update_plugins transient the updates started to show up but again after some time the again the update now button disappears only showing that there is an update for the plugin. I tried to use the following but it is not a recommendable approach:

public function force_update_check() {
    delete_site_transient( 'update_plugins' );
}

Therefore a but help needed to fix the issue.
This is the method for showing update notification

    public function show_update_notification( $file, $plugin ) {

        if ( is_network_admin() ) {
            return;
        }

        if( ! current_user_can( 'update_plugins' ) ) {
            return;
        }

        if( ! is_multisite() ) {
            return;
        }

        if ( $this->name != $file ) {
            return;
        }

        // Remove our filter on the site transient
        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );

        $update_cache = get_site_transient( 'update_plugins' );

        $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();

        if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {

            $version_info = $this->get_cached_version_info();

            if ( false === $version_info ) {
                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );

                $this->set_version_info_cache( $version_info );
            }

            if ( ! is_object( $version_info ) ) {
                return;
            }

            if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {

                $update_cache->response[ $this->name ] = $version_info;

            }

            $update_cache->last_checked = time();
            $update_cache->checked[ $this->name ] = $this->version;

            set_site_transient( 'update_plugins', $update_cache );

        } else {

            $version_info = $update_cache->response[ $this->name ];

        }

        // Restore our filter
        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );

        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {

            // build a plugin list row, with update notification
            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
            # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
            echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
            echo '<td colspan="3" class="plugin-update colspanchange">';
            echo '<div class="update-message notice inline notice-warning notice-alt">';

            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );

            if ( empty( $version_info->download_link ) ) {
                printf(
                    __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
                    esc_html( $version_info->name ),
                    '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
                    esc_html( $version_info->new_version ),
                    '</a>'
                );
            } else {
                printf(
                    __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
                    esc_html( $version_info->name ),
                    '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
                    esc_html( $version_info->new_version ),
                    '</a>',
                    '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
                    '</a>'
                );
            }

            do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );

            echo '</div></td></tr>';
        }
    }

php Session Problems

I have a problem with my Website. It’s not passing session variables between pages. I made a simple 2 files to pass session variables between them but it’s not working.
page1.php code as follows

    <?php
        session_start();
        $_SESSION['id']='3';
        $_SESSION['name']='sameer';
        header('location:page2.php');
        exit();
    ?>

page2.php code as follows

    <?php
        session_start();
        echo $_SESSION['id'].'<br>';
        echo $_SESSION['name'];
        echo 'finish';
    ?>

in my localhost it’s working and showing the two variables and say finish.

in my hosting server it says only finish without passing the variables.

I tried with my hosting technical support team but they did not solve the problem.

is there anything to do to let the server pass the session variables between these two pages.

Thanks

Video dimensions in php [duplicate]

Is there a way to get the width and height of a video in php? I have uploaded images and I can get their dimensions using GD or IMagick but I haven’t found a way to get the dimensions of a video. I don’t want to use getID3.
Thank you.

php documentation
searched on google

Loaders & jquery not working in the livewire pagination

my code is working correctly in the first page, but when I navigate to the second page the loading icons and the jQuery effects not working correctly when I submitting a form.
It’s insert the data without showing the loading icon.

my view

 <x-livewire.form.buttons.save type="submit" title="{{ __('buttons.save') }}" wire:target="form_data.{{ $user->id }}.file" wire:loading.attr="disabled">
                                        <div wire:target="save({{ $user->id }})" wire:loading.remove>
                                            {{ __('buttons.save') }}
                                        </div>

                                        <div wire:target="save({{ $user->id }})" wire:loading>
                                            <i class="fa-solid fa-spinner fa-spin"></i>
                                        </div>
                                    </x-livewire.form.buttons.save>

php

public $page;
public $name = '';
public $badge_number = '';


public $form_data = [];
public $permission_type = [];

protected $queryString = [
    'page',
    'name',
    'badge_number',
];

public function updatingName()
{
    $this->resetPage();
}

public function updatingBadgeNumber(){

    $this->resetPage();
}

public function render()
{
    $name = $this->name;
    $badge_number = $this->badge_number;

    if($name === '' && $badge_number === '')
    {
        $users = User::orderBy('name')
        ->paginate(15);
    }
    else
    {
        $users = User::where('name', 'like', '%' . $name . '%')
        ->where('badge_number', 'like', $badge_number . '%')
        ->orderBy('name')
        ->paginate(15);
    }

    return view('livewire.attendances.daily', [
        'users' => $users,
        'page' => $this->getPage()
    ]);
}