I am using laravel 4.2.8 and Eloquent ORM. When I try to disable it, it does not work. It deletes data from my database. I want to logically delete data physically. Here I give my code to what I tried
model
use Illuminate\Auth\UserInterface;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
class User extends Eloquent implements UserInterface {
protected $table = 'users';
public $timestamps = true;
protected $softDelete = true;
protected $dates = ['deleted_at'];
public static function boot()
{
parent::boot();
static::creating(function($post)
{
$post->created_by = Auth::user()->id;
$post->updated_by = Auth::user()->id;
});
static::updating(function($post)
{
$post->updated_by = Auth::user()->id;
});
static::deleting(function($post)
{
$post->deleted_by = Auth::user()->id;
});
}
}
controller
public function destroy($id) {
$user = User::find($id);
$user->delete();
return Redirect::to('admin/user');
}
user3936104
source
share