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-10-29 19:34:50 +02:00
|
|
|
|
2021-08-22 22:23:17 +02:00
|
|
|
return redirect()->back();
|
|
|
|
}
|
2021-08-22 23:32:54 +02:00
|
|
|
|
2022-05-01 20:30:14 +02:00
|
|
|
public function destroy(Member $member, Membership $membership, NamiSettings $settings): RedirectResponse
|
2021-08-22 23:32:54 +02:00
|
|
|
{
|
2022-05-01 20:30:14 +02:00
|
|
|
$api = $settings->login();
|
|
|
|
$api->deleteMembership(
|
|
|
|
$member->nami_id,
|
|
|
|
$api->membership($member->nami_id, $membership->nami_id)
|
|
|
|
);
|
2021-08-22 23:32:54 +02:00
|
|
|
$membership->delete();
|
2022-05-01 20:30:14 +02:00
|
|
|
$member->syncVersion();
|
2021-08-22 23:32:54 +02:00
|
|
|
|
|
|
|
return redirect()->back();
|
|
|
|
}
|
2021-08-22 22:23:17 +02:00
|
|
|
}
|