add some missing auto-deletes if refcount reaches zero
This commit is contained in:
@@ -24,6 +24,22 @@ class Proposal extends Model
|
||||
{
|
||||
use Reportable;
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function(Proposal $self) {
|
||||
$self->reportsOf()->delete();
|
||||
|
||||
// update refcounts
|
||||
$rev = $self->revision;
|
||||
$rev->decrement('refs');
|
||||
|
||||
// Delete the revision if it has no other refs (manually, to update row refs)
|
||||
if ($rev->refs <= 0) $rev->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/** Authoring user */
|
||||
public function author()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user