<commit_before><?php namespace Ivacuum\Generic\Traits;

trait SoftDeleteTrait
{
    public function softDelete()
    {
        $query = $this->newQueryWithoutScopes()->where($this->getKeyName(), $this->getKey());

        $this->{$this->getStatusDeletedColumn()} = $this->getStatusDeletedValue();

        $columns = [$this->getStatusDeletedColumn() => $this->getStatusDeletedValue()];

        if ($this->timestamps) {
            $time = $this->freshTimestamp();

            $this->{$this->getUpdatedAtColumn()} = $time;

            $columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);
        }

        $query->update($columns);
    }

    public function trashed()
    {
        return (int) $this->{$this->getStatusDeletedColumn()} === (int) $this->getStatusDeletedValue();
    }

    public function getStatusDeletedColumn(): string
    {
        return defined('static::STATUS_DELETED_COLUMN') ? static::STATUS_DELETED_COLUMN : 'status';
    }

    public function getStatusDeletedValue(): int
    {
        if (!defined('static::STATUS_DELETED')) {
            throw new \Exception('Не найден STATUS_DELETED у модели');
        }

        return static::STATUS_DELETED;
    }
}<commit_msg>Теперь можно в событии saving распознать выполнение soft delete<commit_after><?php namespace Ivacuum\Generic\Traits;

trait SoftDeleteTrait
{
    public function softDelete(): bool
    {
        $this->{$this->getStatusDeletedColumn()} = $this->getStatusDeletedValue();

        return $this->save();
    }

    public function trashed()
    {
        return (int) $this->{$this->getStatusDeletedColumn()} === (int) $this->getStatusDeletedValue();
    }

    public function getStatusDeletedColumn(): string
    {
        return defined('static::STATUS_DELETED_COLUMN') ? static::STATUS_DELETED_COLUMN : 'status';
    }

    public function getStatusDeletedValue(): int
    {
        if (!defined('static::STATUS_DELETED')) {
            throw new \Exception('Не найден STATUS_DELETED у модели');
        }

        return static::STATUS_DELETED;
    }
}
{'fraction_non_alphanumeric': 0.14499758337361043, 'fraction_numerical': 0.0, 'mean_word_length': 3.1733870967741935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5913243', 'n_tokens_mistral': 608, 'n_tokens_neox': 631, 'n_words': 108}