Added per-item recycle-bin delete and restore

This commit is contained in:
Dan Brown
2020-11-02 22:47:48 +00:00
parent ff7cbd14fc
commit 9e033709a7
14 changed files with 291 additions and 38 deletions

View File

@@ -287,6 +287,22 @@ class Entity extends Ownable
return $path;
}
/**
* Get the parent entity if existing.
* This is the "static" parent and does not include dynamic
* relations such as shelves to books.
*/
public function getParent(): ?Entity
{
if ($this->isA('page')) {
return $this->chapter_id ? $this->chapter()->withTrashed()->first() : $this->book->withTrashed()->first();
}
if ($this->isA('chapter')) {
return $this->book->withTrashed()->first();
}
return null;
}
/**
* Rebuild the permissions for this entity.
*/