Skip to content

Fix SoftDeletes for null values in the DB (not deleted entries). #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ If you don't want to affect the stability of the rest of the packages, you can a

## Installation

Begin by installing the package through Composer. Edit your project's `composer.json` to require `mitchellvanw/laravel-doctrine`.
Begin by installing the package through Composer. Edit your project's `composer.json` to require `rsamborski/laravel-doctrine`.

> This package is still in it's early stages, but fully functional. Is it possible that the API might change slightly, no drastic changes.

```php
"require": {
"mitchellvanw/laravel-doctrine": "0.5.*"
"rsamborski/laravel-doctrine": "0.5.*"
}
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mitchellvanw/laravel-doctrine",
"name": "rsamborski/laravel-doctrine",
"description": "The Doctrine 2 implementation that melts with Laravel 4",
"version": "0.5.0",
"keywords": ["doctrine", "doctrine 2", "orm", "laravel"],
Expand Down
6 changes: 3 additions & 3 deletions src/Console/SchemaUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function fire()
{
$this->info('Checking if database needs updating....');
$clean = $this->option('clean');
$sql = $this->tool->getUpdateSchemaSql($this->metadata->getAllMetadata(), $clean);
$sql = $this->tool->getUpdateSchemaSql($this->metadata->getAllMetadata(), !$clean);
if (empty($sql)) {
$this->info('No updates found.');
return;
Expand All @@ -62,7 +62,7 @@ public function fire()
$this->info(implode(';' . PHP_EOL, $sql));
} else {
$this->info('Updating database schema....');
$this->tool->updateSchema($this->metadata->getAllMetadata());
$this->tool->updateSchema($this->metadata->getAllMetadata(), !$clean);
$this->info('Schema has been updated!');
}
}
Expand All @@ -71,7 +71,7 @@ protected function getOptions()
{
return [
['sql', false, InputOption::VALUE_NONE, 'Dumps SQL query and does not execute update.'],
['clean', null, InputOption::VALUE_OPTIONAL, 'When using clean model all non-relevant to this metadata assets will be cleared.']
['clean', null, InputOption::VALUE_NONE, 'Use this flag to clear all assets from the database not relevant to the current metadata.']
];
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Traits/SoftDeletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function setDeletedAt(DateTime $deletedAt)

public function isDeleted()
{
return new DateTime > $this->deletedAt;
if($this->deletedAt == null) return false;
else return new DateTime > $this->deletedAt;
}
}