v1.5.18 Multiple events works, only admin pages is missing some pdf, view user and jpg functions

This commit is contained in:
2021-04-28 15:14:31 +02:00
parent 42de425aba
commit 027a99b002
6 changed files with 183 additions and 24 deletions
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\UserEvent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@@ -129,7 +130,45 @@ class UserEventController extends Controller
}
// If not, then it keeps going and saves and shows a success message
$UserEvent = new UserEvent($data);
$UserEvent = new UserEvent();
$UserEvent->event_id = $request->event_id;
$UserEvent->user_id = auth()->user()->id;
$UserEvent->save();
if (request()->cookie('languagesSetting') == "dk")
return '<p class="text-center"><b>Du er hermed tilmeldt denne aktivitet!</b></p>';
if (request()->cookie('languagesSetting') == "en")
return '<p class="text-center"><b>You are now participating in this event!</b></p>';
return '<p class="text-center"><b>Du er hermed tilmeldt denne aktivitet!</b></p>';
}
//Signs a user up to a multiple event via ajax
public function createmultiajax(Request $request)
{
// Get written data from events.index
$data = $request->validate([
"multiple_event_id" => "required|max:255"
]);
// Check the UserEvent table if there is a row that has the user_id AND the event_id
$getTableInfo = UserEvent::where('user_id', auth()->user()->id)
->where('multiple_event_id', $request->multiple_events_id)->get();
// If the row has both, then go back and show an error - Cause you're not allowed to be on the same event twice.
if (count($getTableInfo) > 0) {
if (request()->cookie('languagesSetting') == "dk")
return '<p class="text-center"><b>Du har allerede tilmeldt dig denne Aktivitet!</b></p>';
if (request()->cookie('languagesSetting') == "en")
return '<p class="text-center"><b>You are already participating in this event!</b></p>';
return '<p class="text-center"><b>Du har allerede tilmeldt dig denne Aktivitet!</b></p>';
}
// If not, then it keeps going and saves and shows a success message
$UserEvent = new UserEvent();
$UserEvent->multiple_event_id = $request->multiple_event_id;
$UserEvent->user_id = auth()->user()->id;
$UserEvent->save();
@@ -149,6 +188,28 @@ class UserEventController extends Controller
->where('event_id', $request->event_id);
// If you are in the Event, then remove yourself.
if (count($UserEvent->get()) > 0) {
// If not, then it keeps going and saves and shows a success message
$UserEvent->delete();
if (request()->cookie('languagesSetting') == "dk")
return '<p class="text-center"><b>Du er hermed afmeldt aktiviteten!</b></p>';
if (request()->cookie('languagesSetting') == "en")
return '<p class="text-center"><b>You are no longer participating in this event!</b></p>';
return '<p class="text-center"><b>Du er hermed afmeldt aktiviteten!</b></p>';
}
}
//Removes a users participation in an event via ajax
public function createmultiajaxcancel(Request $request)
{
// Check the UserEvent table if there is a row that has the user_id AND the event_id
$UserEvent = UserEvent::where('user_id', auth()->user()->id)
->where('multiple_event_id', $request->multiple_event_id);
// If you are in the Event, then remove yourself.
if (count($UserEvent->get()) > 0) {
// If not, then it keeps going and saves and shows a success message