The withTrashed method in PHP allows you to include soft-deleted records in your query results. When you soft-delete a record, it is not actually removed from the database, but instead marked as deleted. Using withTrashed, you can retrieve these records along with the non-deleted ones.
For example, if you have a "users" table with a "deleted_at" column that marks deleted records, you can retrieve all users, including deleted ones, like this:
$users = User::withTrashed()->get();
This will return all user records, including those that have been soft-deleted.
Another example is retrieving only the soft-deleted records:
$deletedUsers = User::onlyTrashed()->get();
This will return only the soft-deleted user records.
The package/library used for this functionality is typically Laravel's Eloquent ORM.
PHP User::withTrashed - 27 examples found. These are the top rated real world PHP examples of User::withTrashed extracted from open source projects. You can rate examples to help us improve the quality of examples.