PHPackages                             to-mo-ki/laravel-soft-deletes-value - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. to-mo-ki/laravel-soft-deletes-value

ActiveLibrary[Database &amp; ORM](/categories/database)

to-mo-ki/laravel-soft-deletes-value
===================================

Allow customizing the "undeleted" value for Laravel Soft Deletes.

v0.1.1(4mo ago)02↓93.8%MITPHPPHP ^8.2

Since Feb 23Pushed 4mo agoCompare

[ Source](https://github.com/to-mo-ki/laravel-soft-deletes-value)[ Packagist](https://packagist.org/packages/to-mo-ki/laravel-soft-deletes-value)[ RSS](/packages/to-mo-ki-laravel-soft-deletes-value/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Laravel Soft Deletes Value
==========================

[](#laravel-soft-deletes-value)

[![Total Downloads](https://camo.githubusercontent.com/06dd4d60bd50c44ee5a73a9d3f135545f09a8286007f9c90c7498aae74e82423/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f2d6d6f2d6b692f6c61726176656c2d736f66742d64656c657465732d76616c7565)](https://packagist.org/packages/to-mo-ki/laravel-soft-deletes-value)[![Latest Stable Version](https://camo.githubusercontent.com/ebd93141b31e5f2dce40416af1987d5bf488b1331e06dff611c45a1519c9e98f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f2d6d6f2d6b692f6c61726176656c2d736f66742d64656c657465732d76616c7565)](https://packagist.org/packages/to-mo-ki/laravel-soft-deletes-value)[![License](https://camo.githubusercontent.com/b3e0a1f074c9ff324a0ed0aae4eb0f3c190667d4f0b1a1b44abd78f3ab1e7af9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f2d6d6f2d6b692f6c61726176656c2d736f66742d64656c657465732d76616c7565)](https://packagist.org/packages/to-mo-ki/laravel-soft-deletes-value)

Allow customizing the "undeleted" (active) value for Laravel Soft Deletes.

Currently, Laravel's native Soft Deletes assumes that `NULL` indicates an active (undeleted) record. However, this assumption conflicts with database partitioning requirements in databases like MySQL. In MySQL, all columns used in the partitioning expression must be part of every unique key on the table, including the primary key. Since primary key columns cannot be nullable, it is impossible to use a nullable `deleted_at` column as a partition key.

With this package, developers can define a non-null "undeleted" value (e.g., `'9999-12-31 23:59:59'`). This allows `deleted_at` to be defined as `NOT NULL`, making it eligible for use in partitioning keys while retaining all native Soft Deletes functionality.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require to-mo-ki/laravel-soft-deletes-value
```

Usage
-----

[](#usage)

Replace Laravel's default `Illuminate\Database\Eloquent\SoftDeletes` trait with `Tomoki\SoftDeletesValue\SoftDeletes` in your Eloquent models.

Then, define the `$undeletedValue` property indicating what value represents an active, non-deleted state.

```
