Last active
March 17, 2020 03:41
-
-
Save blood72/6ad4248322e334c04773ae816a721812 to your computer and use it in GitHub Desktop.
Determine if the model implements soft deletes and does soft delete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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