Laravel 4.2 Soft Delete not working correctly

518 views Asked by At

I just started to work on a project with a clean laravel 4.2 installation (from 5 days ago). I have a model defined like this:

<?php

use Illuminate\Database\Eloquent\SoftDeletingTrait;

class Code extends Eloquent {

    use SoftDeletingTrait;

    protected $dates = ['deleted_at'];

    public function group() {
        return $this->belongsTo('Group');
    }

    public function user() {
        return $this->belongsTo('User');
    }

}

The table is created with $table->softDeletes();, and has a nullable deleted_at column.

Now when I delete a record with Code::find(1)->delete(); the deleted_at column is filled with current date.

But then when I do Code::all(), or Code::find(1), the result includes soft deleted records, but I expected it not to include them unless I specifically want deleted results...

I've already read http://laravel.com/docs/4.2/upgrade#upgrade-4.2 and my model reflects what is written there.

Am I missing something, or is this a bug in 4.2?

0

There are 0 answers