2020-06-02 23:45:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Member;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\Request;
|
2021-04-11 11:19:55 +02:00
|
|
|
use App\Gender;
|
|
|
|
use App\Fee;
|
2021-04-11 11:44:51 +02:00
|
|
|
use App\Region;
|
|
|
|
use App\Country;
|
|
|
|
use App\Nationality;
|
|
|
|
use App\Confession;
|
2021-04-11 18:17:40 +02:00
|
|
|
use App\Bill\BillKind;
|
2020-06-02 23:45:25 +02:00
|
|
|
|
|
|
|
class MemberController extends Controller
|
|
|
|
{
|
2021-04-11 20:01:37 +02:00
|
|
|
|
2020-06-02 23:45:25 +02:00
|
|
|
public function index(Request $request) {
|
2021-04-11 01:25:40 +02:00
|
|
|
session()->put('menu', 'member');
|
|
|
|
session()->put('title', 'Mitglieder');
|
|
|
|
|
|
|
|
return \Inertia::render('member/Index', [
|
2021-06-22 00:14:34 +02:00
|
|
|
'data' => MemberResource::collection(Member::search($request->query('search', null))->with('billKind')->paginate(15)),
|
|
|
|
'toolbar' => [ ['href' => route('member.create'), 'label' => 'Mitglied anlegen', 'color' => 'primary', 'icon' => 'plus'] ],
|
2020-06-02 23:45:25 +02:00
|
|
|
]);
|
|
|
|
}
|
2021-04-11 11:19:55 +02:00
|
|
|
|
|
|
|
public function edit(Member $member, Request $request) {
|
|
|
|
session()->put('menu', 'member');
|
|
|
|
session()->put('title', 'Mitglied bearbeiten');
|
|
|
|
|
|
|
|
return \Inertia::render('member/Edit', [
|
2021-04-11 18:17:40 +02:00
|
|
|
'billKinds' => BillKind::get()->pluck('name', 'id'),
|
2021-04-11 17:02:49 +02:00
|
|
|
'genders' => Gender::get()->pluck('name', 'id'),
|
2021-04-11 11:44:51 +02:00
|
|
|
'countries' => Country::get()->pluck('name', 'id'),
|
|
|
|
'regions' => Region::where('is_null', false)->get()->pluck('name', 'id'),
|
|
|
|
'nationalities' => Nationality::get()->pluck('name', 'id'),
|
|
|
|
'confessions' => Confession::where('is_null', false)->get()->pluck('name', 'id'),
|
2021-04-11 11:19:55 +02:00
|
|
|
'fees' => Fee::get()->pluck('name', 'id'),
|
|
|
|
'data' => new MemberResource($member)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-04-11 20:01:37 +02:00
|
|
|
public function update(Member $member, MemberRequest $request) {
|
|
|
|
$request->persistUpdate($member);
|
2021-04-11 11:19:55 +02:00
|
|
|
|
|
|
|
return redirect()->route('member.index');
|
|
|
|
}
|
2020-06-02 23:45:25 +02:00
|
|
|
}
|