Skip to content

Instantly share code, notes, and snippets.

@blood72
Last active March 17, 2020 03:41
Show Gist options
  • Save blood72/6ad4248322e334c04773ae816a721812 to your computer and use it in GitHub Desktop.
Save blood72/6ad4248322e334c04773ae816a721812 to your computer and use it in GitHub Desktop.
Determine if the model implements soft deletes and does soft delete.
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Model;
trait isSoftDeleting
{
/**
* Determine if the model implements soft deletes and does soft deleting.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return bool
*/
public static function isSoftDeleting(Model $model)
{
return method_exists($model, 'isForceDeleting') and ! $model->isForceDeleting();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment