z-song / laravel-admin

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

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

Closed xxl4 closed 5 days ago

xxl4 commented 10 months 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: