Why should Model has a real increment method

Kamicloud posted 2 weeks ago

I got an IDE warning when using increment on a model, The code works.

error message

I found that increment was route to Model::__call -> Model::increment -> Model::incrementOrDecrement -> Builder::increment

Why can't remove increment method and route do routing in __call. I removed increment method and try follows code, it works also.

     * Handle dynamic method calls into the model.
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
    public function __call($method, $parameters)
        if (in_array($method, ['increment', 'decrement'])) {
            return $this->forwardCallTo($this->newQuery()->where(
                $this->getKeyName(), $this->getKey()
            ), $method, $parameters);


        return $this->forwardCallTo($this->newQuery(), $method, $parameters);

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us