Skip to content

Commit

Permalink
delete report pins
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanSenturk committed Dec 8, 2023
1 parent 04896bf commit 311022e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/Jobs/Common/DeleteReport.php
Expand Up @@ -11,6 +11,7 @@ public function handle(): bool
{
\DB::transaction(function () {
$this->deleteFavorite();
$this->deletePin();

$this->model->delete();
});
Expand Down Expand Up @@ -43,4 +44,28 @@ public function deleteFavorite()
setting()->save();
}
}

public function deletePin()
{
$pins = setting('favorites.report', []);

if (empty($pins)) {
return;
}

foreach ($pins as $user_id => $user_pins) {
$user_pins = json_decode($user_pins, true);

foreach ($user_pins as $key => $pin) {
if ($this->model->id == $pin) {
unset($user_pins[$key]);

break;
}
}

setting()->set('favorites.report.' . $user_id, json_encode($user_pins));
setting()->save();
}
}
}

0 comments on commit 311022e

Please sign in to comment.