laravel / nova-issues

554 stars 34 forks source link

Resource isSoftDeleted() method should check the trashed() method in case it was overridden. #3403

Closed jonagoldman closed 3 years ago

jonagoldman commented 3 years ago

Description:

In my app models, I override the trashed() method from the SoftDeletes trait to add some custom logic.

But in Laravel\Nova\Resource, this method is not used:

public function isSoftDeleted()
{
    return static::softDeletes() && ! is_null($this->resource->{$this->resource->getDeletedAtColumn()});
}

This could be simplified to:

public function isSoftDeleted()
{
    return static::softDeletes() && $this->resource->trashed();
}

This will respect overrides and reduce code duplication.

crynobone commented 3 years ago

This has been fixed in v3.27.0: https://nova.laravel.com/releases/3.27.0