valera
valera

Reputation: 79

Overloading truncate laravel 5

Hi i try this in my model

public static function truncate(){
    /*my some code*/
    static::truncate();
}


MyModel::truncate();

but i get recursive call. How to organize it correctly?

Upvotes: 0

Views: 52

Answers (1)

Jonas Staudenmeir
Jonas Staudenmeir

Reputation: 25906

Use this:

public static function truncate() {
    /*my some code*/
    (new static)->newQuery()->truncate();
}

Upvotes: 2

Related Questions