Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May be the inputFilter have a Bug, when the filter value eq string "0" #5837

Closed
xxl4 opened this issue Nov 17, 2023 · 0 comments
Closed

May be the inputFilter have a Bug, when the filter value eq string "0" #5837

xxl4 opened this issue Nov 17, 2023 · 0 comments

Comments

@xxl4
Copy link

xxl4 commented Nov 17, 2023

  • Laravel Version: #.#.#
  • PHP Version: 7.4
  • Laravel-admin: #.#.#

master

Description:

When my code have status include 0, the input filter don't work fine.

`

/**
 * Add a binding to the query.
 *
 * @param string     $value
 * @param Model|null $model
 */
public function addBinding($value, Model $model)
{
    if (empty($value)) {  // when value is string "0" will not work fine
        return;
    }

    if ($this->type == 'like') {
        $model->where($this->getColumnName(), 'like', "%{$value}%");

        return;
    }

    if (in_array($this->type, ['date', 'time'])) {
        $method = 'where'.ucfirst($this->type);
        $model->{$method}($this->getColumnName(), $value);

        return;
    }

    $model->where($this->getColumnName(), $value);
}

`

so and now , fix it to

`

/**
* Add a binding to the query.
*
* @param string $value
* @param Model|null $model
*/
public function addBinding($value, Model $model)
{

    if (empty($value)) {
        //return;
    }
    
    if($value==NULL) {
        return ;
    }


    if ($this->type == 'like') {
        $model->where($this->getColumnName(), 'like', "%{$value}%");

        return;
    }

    if (in_array($this->type, ['date', 'time'])) {
        $method = 'where'.ucfirst($this->type);
        $model->{$method}($this->getColumnName(), $value);

        return;
    }

    $model->where($this->getColumnName(), $value);
}

`

pls check it, thank you!

Steps To Reproduce:

@xxl4 xxl4 closed this as completed Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant