improve toggle favorite log
This commit is contained in:
parent
4ea2871c6d
commit
0a412d48a4
2 changed files with 6 additions and 4 deletions
|
|
@ -15,10 +15,14 @@ return [
|
|||
$user = Find::user($data->userUuid);
|
||||
$favoriteForUsers = $file->favoriteForUsers()->toUsers();
|
||||
|
||||
$action = null;
|
||||
|
||||
if ($favoriteForUsers->has($user)) {
|
||||
$favoriteForUsers->remove($user);
|
||||
$action = 'retirée des';
|
||||
} else {
|
||||
$favoriteForUsers->add($user);
|
||||
$action = 'ajoutée aux';
|
||||
}
|
||||
|
||||
$array = $favoriteForUsers->toArray();
|
||||
|
|
@ -28,6 +32,6 @@ return [
|
|||
'favoriteForUsers' => $yaml
|
||||
]);
|
||||
|
||||
return $favoriteForUsers->toJson();
|
||||
return json_encode('Image ' . $action . ' favoris de l\'utilisateur ' . $user->email() . '.');
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue