z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

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

Closed xxl4 closed 1 month ago

xxl4 commented 1 year ago

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

`

/**

`

pls check it, thank you!

Steps To Reproduce: