%PDF- %PDF-
Direktori : /www/loslex/demo/app/Http/Controllers/ |
Current File : //www/loslex/demo/app/Http/Controllers/OrganizerGroupUserController.php |
<?php namespace App\Http\Controllers; use App\Models\OrganizerGroup; use App\Models\OrganizerGroupUser; use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; class OrganizerGroupUserController extends Controller { /** * Store a newly created resource in storage. */ public function store(Request $request) : RedirectResponse { // $request->validateWithBag('addOrgMember', [ 'user_id' => 'required|numeric|exists:users,id', 'organizer_group_id' => 'required|numeric|exists:organizer_groups,id', ]); $newmember = OrganizerGroupUser::create([ 'user_id' => $request->user_id, 'organizer_group_id' => $request->organizer_group_id, ]); $username = User::where('id', $request->user_id)->value('username'); $groupname = OrganizerGroup::where('id', $request->organizer_group_id)->value('name'); $orgname = Auth::user()->username; Log::info("Organizer {$orgname} added user {$username} to organizer group {$groupname}", [ 'group' => $request->organizer_group_id, 'user' => $request->user_id, 'organizer' => Auth::user()->id ]); return redirect(route('organizer.show', $newmember->organizer_group_id)); } /** * Remove the specified resource from storage. */ public function destroy(OrganizerGroupUser $orgmember) : RedirectResponse { $orgmember->delete(); $username = User::where('id', $orgmember->user_id)->value('username'); $groupname = OrganizerGroup::where('id', $orgmember->organizer_group_id)->value('name'); $orgname = Auth::user()->username; Log::info("Organizer {$orgname} removed user {$username} from organizer group {$groupname}", [ 'group' => $orgmember->organizer_group_id, 'user' => $orgmember->user_id, 'organizer' => Auth::user()->id ]); return redirect(route('organizer.show', $orgmember->organizer_group_id)); } }