diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index c99622b..81f6dcf 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -358,6 +358,42 @@ class UserController extends Controller return redirect()->route("users.index"); } + public function createajax() { + // Check the UserEvent table if there is a row that has the user_id AND the event_id + $User = User::query()->where('id', '=', auth()->user()->id); + + // If you are in the Event, then remove yourself. + if (count($User->get()) > 0) { + // If not, then it keeps going and saves and shows a success message + $User->update([ "wants_emails" => true ]); + + if (request()->cookie('languagesSetting') == "dk") + return '
Du får nu mails, når der kommer nyheder!
'; + if (request()->cookie('languagesSetting') == "en") + return "You'll now receive a mail when there's news!
"; + + return 'Du får nu mails, når der kommer nyheder!
'; + } + } + + public function createajaxcancel() { + // Check the UserEvent table if there is a row that has the user_id AND the event_id + $User = User::query()->where('id', '=', auth()->user()->id); + + // If you are in the Event, then remove yourself. + if (count($User->get()) > 0) { + // If not, then it keeps going and saves and shows a success message + $User->update([ "wants_emails" => false ]); + + if (request()->cookie('languagesSetting') == "dk") + return 'Du får ikke mails mere, når kommer nyheder!
'; + if (request()->cookie('languagesSetting') == "en") + return "You'll no longer receive a mail when there's news!
"; + + return 'Du får ikke mails mere, når kommer nyheder!
'; + } + } + /*******************************************/ /* Search and settings */ /*******************************************/ diff --git a/skolehjem/resources/views/app/settings/index.blade.php b/skolehjem/resources/views/app/settings/index.blade.php index 3126a0f..6ec4513 100644 --- a/skolehjem/resources/views/app/settings/index.blade.php +++ b/skolehjem/resources/views/app/settings/index.blade.php @@ -97,13 +97,14 @@