1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Update email preferences based on request action

This commit is contained in:
Benjamin Beganović 2024-01-19 15:20:19 +01:00
parent f6402f87a5
commit 89309ac713

View File

@ -36,11 +36,10 @@ class EmailPreferencesController extends Controller
public function update(string $entity, string $invitation_key, Request $request): \Illuminate\Http\RedirectResponse
{
$class = "\\App\\Models\\" . ucfirst(Str::camel($entity)) . 'Invitation';
$invitation = $class::withTrashed()->where('key', $invitation_key)->firstOrFail();
$invitation->contact->is_locked = $request->has('receive_emails') ? false : true;
$invitation->contact->is_locked = $request->action === 'unsubscribe' ? true : false;
$invitation->contact->push();
if ($invitation->contact->is_locked) {