Querying soft deleted models

With soft deletion the records are 'deleted' by defining this in a model like this:

class Model extends BaseModel
{
    protected $table = 'semesters';
    protected $primaryKey = 'id';

    use SoftDeletes;

    const CREATED_AT = 'pcdate';
    const UPDATED_AT = 'pmdate';
    const DELETED_AT = 'pddate';

So when you delete a record the 'pddate' field will be filled with the datetime at the time of deletion.

Querying soft deletions

To also get soft deleted models:

$trashedAndNotTrashed = Model::withTrashed()->get();

Only soft deleted models in your results:

$onlySoftDeleted = Model::onlyTrashed()->get();
Last update: January 18th at 11:13am