Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saber13812002/896417b374ec3c69bddd25cb344e6759 to your computer and use it in GitHub Desktop.
Save saber13812002/896417b374ec3c69bddd25cb344e6759 to your computer and use it in GitHub Desktop.
/**
* Set empty nullable fields to null
* @param object $model
*/
protected static function setNullables(object $model): void
{
foreach ($model->nullable as $field) {
if (empty($model->{$field})) {
$model->{$field} = null;
}
}
}
public function wasDeleted()
{
return !($this->deleted_at == null);
}
@saber13812002
Copy link
Author

        if ($user->trashed()) {
            $user->restore();
            $user->setAllFieldsNull();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment