adrema/app/Membership/MembershipController.php

32 lines
846 B
PHP
Raw Normal View History

2021-08-22 22:23:17 +02:00
<?php
namespace App\Membership;
use App\Http\Controllers\Controller;
use App\Member\Member;
2021-08-22 23:32:54 +02:00
use App\Member\Membership;
2022-03-06 02:57:39 +01:00
use App\Membership\Requests\StoreRequest;
use App\Setting\NamiSettings;
2021-08-22 22:23:17 +02:00
use Illuminate\Http\RedirectResponse;
class MembershipController extends Controller
{
2022-03-06 02:57:39 +01:00
public function store(Member $member, StoreRequest $request, NamiSettings $settings): RedirectResponse
2021-08-22 22:23:17 +02:00
{
2022-03-06 02:57:39 +01:00
$request->persist($member, $settings);
2021-08-22 22:23:17 +02:00
return redirect()->back();
}
2021-08-22 23:32:54 +02:00
public function destroy(Member $member, Membership $membership): RedirectResponse
{
auth()->user()->api()->group($member->group->nami_id)->member($member->nami_id)
->deleteMembership($membership->nami_id);
$membership->delete();
$member->syncVersion(auth()->user()->api());
2021-08-22 23:32:54 +02:00
return redirect()->back();
}
2021-08-22 22:23:17 +02:00
}