mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-06 18:54:33 +08:00
Added deletion of favourites on entity/user delete
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
<?php namespace BookStack\Auth;
|
<?php namespace BookStack\Auth;
|
||||||
|
|
||||||
|
use BookStack\Actions\Favourite;
|
||||||
use BookStack\Api\ApiToken;
|
use BookStack\Api\ApiToken;
|
||||||
use BookStack\Entities\Tools\SlugGenerator;
|
use BookStack\Entities\Tools\SlugGenerator;
|
||||||
use BookStack\Interfaces\Loggable;
|
use BookStack\Interfaces\Loggable;
|
||||||
@ -240,6 +241,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||||||
return $this->hasMany(ApiToken::class);
|
return $this->hasMany(ApiToken::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the favourite instances for this user.
|
||||||
|
*/
|
||||||
|
public function favourites(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Favourite::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last activity time for this user.
|
* Get the last activity time for this user.
|
||||||
*/
|
*/
|
||||||
|
@ -184,6 +184,7 @@ class UserRepo
|
|||||||
{
|
{
|
||||||
$user->socialAccounts()->delete();
|
$user->socialAccounts()->delete();
|
||||||
$user->apiTokens()->delete();
|
$user->apiTokens()->delete();
|
||||||
|
$user->favourites()->delete();
|
||||||
$user->delete();
|
$user->delete();
|
||||||
|
|
||||||
// Delete user profile images
|
// Delete user profile images
|
||||||
|
@ -317,6 +317,7 @@ class TrashCan
|
|||||||
$entity->jointPermissions()->delete();
|
$entity->jointPermissions()->delete();
|
||||||
$entity->searchTerms()->delete();
|
$entity->searchTerms()->delete();
|
||||||
$entity->deletions()->delete();
|
$entity->deletions()->delete();
|
||||||
|
$entity->favourites()->delete();
|
||||||
|
|
||||||
if ($entity instanceof HasCoverImage && $entity->cover) {
|
if ($entity instanceof HasCoverImage && $entity->cover) {
|
||||||
$imageService = app()->make(ImageService::class);
|
$imageService = app()->make(ImageService::class);
|
||||||
|
Reference in New Issue
Block a user