diff --git a/app/Fee.php b/app/Fee.php index 4acd72ed..631453d5 100644 --- a/app/Fee.php +++ b/app/Fee.php @@ -2,10 +2,11 @@ namespace App; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\Factories\HasFactory; use App\Member\Member; use App\Payment\Subscription; +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; class Fee extends Model { @@ -14,8 +15,8 @@ class Fee extends Model public $fillable = ['name', 'nami_id']; public $timestamps = false; - - public function subscriptions() { + public function subscriptions(): HasMany + { return $this->hasMany(Subscription::class); } } diff --git a/app/Group.php b/app/Group.php index 58322289..f3e4bf47 100644 --- a/app/Group.php +++ b/app/Group.php @@ -12,7 +12,8 @@ class Group extends Model public $fillable = ['nami_id', 'name']; public $timestamps = false; - public static function nami($id) { + public static function nami(int $id): self + { return static::firstWhere('nami_id', $id); } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2ebf2cf0..33f4e5f6 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -4,10 +4,11 @@ namespace App\Http\Controllers; use App\Http\Views\HomeView; use Illuminate\Http\Request; +use Inertia\Response; class HomeController extends Controller { - public function __invoke(Request $request) + public function __invoke(Request $request): Response { session()->put('menu', 'dashboard'); session()->put('title', 'Dashboard'); diff --git a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php index 657a1d7e..2c3fc309 100644 --- a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php +++ b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php @@ -7,7 +7,7 @@ use Closure; class RedirectIfNotInitializedMiddleware { - public $dontRedirect = ['initialize.index', 'initialize.store']; + public array $dontRedirect = ['initialize.index', 'initialize.store']; /** * Handle an incoming request. @@ -29,11 +29,13 @@ class RedirectIfNotInitializedMiddleware return $next($request); } - public function shouldRedirect() { + public function shouldRedirect(): bool + { return !request()->routeIs($this->dontRedirect) && auth()->check(); } - public function initialized() { + public function initialized(): bool + { return \App\Fee::count() > 0; } } diff --git a/app/Http/Views/HomeView.php b/app/Http/Views/HomeView.php index aa1f0326..fc0635c0 100644 --- a/app/Http/Views/HomeView.php +++ b/app/Http/Views/HomeView.php @@ -11,7 +11,8 @@ use App\Payment\Subscription; use Illuminate\Http\Request; class HomeView { - public function index(Request $request) { + public function index(Request $request): array + { /** @var object{a: string} */ $amount = Payment::whereNeedsPayment()->selectRaw('sum(subscriptions.amount) AS a')->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')->first(); $members = Member::whereHasPendingPayment()->count(); diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index f2ff24be..effbc955 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -7,6 +7,7 @@ use App\Course\Models\Course; use App\Member\Member; use App\Member\MemberResource; use App\Payment\ActionFactory; +use App\Payment\Payment; use App\Payment\PaymentResource; use App\Payment\Status; use App\Payment\Subscription; @@ -14,7 +15,8 @@ use App\Subactivity; use Illuminate\Http\Request; class MemberView { - public function index(Request $request, array $filter) { + public function index(Request $request, array $filter): array + { $activities = Activity::with('subactivities')->get(); return [ @@ -39,7 +41,8 @@ class MemberView { ]; } - public function paymentEdit($member, $payment) { + public function paymentEdit(Member $member, Payment $payment): MemberResource + { return $this->additional($member, [ 'model' => new PaymentResource($payment), 'links' => [ ['label' => 'Zurück', 'href' => route('member.payment.index', ['member' => $member]) ] ], @@ -47,7 +50,8 @@ class MemberView { ]); } - public function paymentIndex($member) { + public function paymentIndex(Member $member): MemberResource + { return $this->additional($member, [ 'model' => null, 'links' => [ @@ -58,7 +62,8 @@ class MemberView { ]); } - private function additional($member, $overwrites = []) { + private function additional(Member $member, array $overwrites = []): MemberResource + { return (new MemberResource($member->load('payments'))) ->additional(array_merge([ 'subscriptions' => Subscription::pluck('name', 'id'), diff --git a/app/Initialize/ActivityCreator.php b/app/Initialize/ActivityCreator.php index 75d3b32a..d773dbe9 100644 --- a/app/Initialize/ActivityCreator.php +++ b/app/Initialize/ActivityCreator.php @@ -2,6 +2,8 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; + class ActivityCreator { private array $tries = [ @@ -12,9 +14,9 @@ class ActivityCreator { '€ Mitglied', 'Schnuppermitgliedschaft', ]; - - public function createFor($api, int $groupId) { + public function createFor(Api $api, int $groupId): void + { $api->activities($groupId)->each(function($activity) use ($api) { $activity = \App\Activity::updateOrCreate(['nami_id' => $activity->id], [ 'nami_id' => $activity->id, diff --git a/app/Initialize/InitializeActivities.php b/app/Initialize/InitializeActivities.php index 4dbfa0be..4678fe8d 100644 --- a/app/Initialize/InitializeActivities.php +++ b/app/Initialize/InitializeActivities.php @@ -2,17 +2,19 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\NamiUser; class InitializeActivities { - private $api; + private Api $api; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle(NamiUser $user) { + public function handle(NamiUser $user): void + { app(ActivityCreator::class)->createFor($this->api, $user->getNamiGroupId()); } } diff --git a/app/Initialize/InitializeConfessions.php b/app/Initialize/InitializeConfessions.php index 48b79a81..878da3ec 100644 --- a/app/Initialize/InitializeConfessions.php +++ b/app/Initialize/InitializeConfessions.php @@ -3,17 +3,19 @@ namespace App\Initialize; use App\Confession; +use Zoomyboy\LaravelNami\Api; class InitializeConfessions { - private $api; - public $nullName = 'ohne Konfession'; + private Api $api; + public string $nullName = 'ohne Konfession'; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle() { + public function handle(): void + { $this->api->confessions()->each(function($confession) { Confession::create(['nami_id' => $confession->id, 'name' => $confession->name, 'is_null' => $this->nullName === $confession->name]); }); diff --git a/app/Initialize/InitializeCountries.php b/app/Initialize/InitializeCountries.php index 450a3a33..63ebcd98 100644 --- a/app/Initialize/InitializeCountries.php +++ b/app/Initialize/InitializeCountries.php @@ -2,15 +2,18 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; + class InitializeCountries { - private $api; + private Api $api; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle() { + public function handle(): void + { $this->api->countries()->each(function($country) { \App\Country::create(['nami_id' => $country->id, 'name' => $country->name]); }); diff --git a/app/Initialize/InitializeFees.php b/app/Initialize/InitializeFees.php index 2556bfd3..de432274 100644 --- a/app/Initialize/InitializeFees.php +++ b/app/Initialize/InitializeFees.php @@ -2,17 +2,19 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\NamiUser; class InitializeFees { - private $api; + private Api $api; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle(NamiUser $user) { + public function handle(NamiUser $user): void + { $this->api->feesOf($user->getNamiGroupId())->each(function($fee) { \App\Fee::create(['nami_id' => $fee->id, 'name' => $fee->name]) ->subscriptions()->create([ diff --git a/app/Initialize/InitializeGenders.php b/app/Initialize/InitializeGenders.php index a6818666..b5447042 100644 --- a/app/Initialize/InitializeGenders.php +++ b/app/Initialize/InitializeGenders.php @@ -2,17 +2,19 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\NamiUser; class InitializeGenders { - private $api; + private Api $api; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle(NamiUser $user) { + public function handle(NamiUser $user): void + { $this->api->genders()->each(function($gender) { \App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->name]); }); diff --git a/app/Initialize/InitializeJob.php b/app/Initialize/InitializeJob.php index cfbcaab2..010f1262 100644 --- a/app/Initialize/InitializeJob.php +++ b/app/Initialize/InitializeJob.php @@ -15,7 +15,7 @@ class InitializeJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasProgress; - public $user; + public NamiUser $user; public function __construct(NamiUser $user) { diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index af5870e6..92d13afd 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -15,19 +15,22 @@ use App\Region; use App\Subactivity; use Carbon\Carbon; use Illuminate\Database\Eloquent\ModelNotFoundException; +use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\Exceptions\RightException; use Zoomyboy\LaravelNami\Member as NamiMember; +use Zoomyboy\LaravelNami\Membership as NamiMembership; use Zoomyboy\LaravelNami\NamiException; class InitializeMembers { - private $api; + private Api $api; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function getSubscriptionId($member) { + public function getSubscriptionId(NamiMember $member): ?int + { $fee = Fee::firstWhere('nami_id', $member->fee_id ?: -1); if (is_null($fee)) { return null; @@ -36,10 +39,11 @@ class InitializeMembers { return optional($fee->subscriptions()->first())->id; } - public function handle() { + public function handle(): void + { $allMembers = collect([]); - $this->api->search([])->each(function($member) { + $this->api->search([])->each(function(NamiMember $member): void { $member = NamiMember::fromNami($this->api->member($member->group_id, $member->id)); if (!$member->joined_at) { return; @@ -118,7 +122,8 @@ class InitializeMembers { }); } - private function fetchMembership($member, $membership) { + private function fetchMembership(NamiMember $member, array $membership): array + { if ($this->shouldSyncMembership($membership)) { $singleMembership = $this->api->membership($member->id, $membership['id']); app(ActivityCreator::class)->createFor($this->api, $singleMembership['gruppierungId']); @@ -149,7 +154,8 @@ class InitializeMembers { return [$activityId, $subactivityId, $groupId]; } - private function shouldSyncMembership($membership) { + private function shouldSyncMembership(array $membership): bool + { if (!Group::where('name', $membership['entries_gruppierung'])->exists()) { return true; } diff --git a/app/Initialize/InitializeNationalities.php b/app/Initialize/InitializeNationalities.php index 74b0ef47..e0e066cc 100644 --- a/app/Initialize/InitializeNationalities.php +++ b/app/Initialize/InitializeNationalities.php @@ -1,16 +1,19 @@ -api = $api; } - public function handle() { + public function handle(): void + { $this->api->nationalities()->each(function($nationality) { \App\Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]); }); diff --git a/app/Initialize/InitializeRegions.php b/app/Initialize/InitializeRegions.php index af7ba9cf..06496bee 100644 --- a/app/Initialize/InitializeRegions.php +++ b/app/Initialize/InitializeRegions.php @@ -2,16 +2,19 @@ namespace App\Initialize; +use Zoomyboy\LaravelNami\Api; + class InitializeRegions { - private $api; - private $nullName = 'Nicht-DE'; + private Api $api; + private string $nullName = 'Nicht-DE'; - public function __construct($api) { + public function __construct(Api $api) { $this->api = $api; } - public function handle() { + public function handle(): void + { $this->api->regions()->each(function($region) { \App\Region::create(['nami_id' => $region->id, 'name' => $region->name, 'is_null' => $region->name == $this->nullName]); }); diff --git a/app/Member/MemberConfirmController.php b/app/Member/MemberConfirmController.php index daa9c6f2..db717ff9 100644 --- a/app/Member/MemberConfirmController.php +++ b/app/Member/MemberConfirmController.php @@ -3,11 +3,13 @@ namespace App\Member; use App\Http\Controllers\Controller; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class MemberConfirmController extends Controller { - public function __invoke(Request $request, Member $member) { + public function __invoke(Request $request, Member $member): RedirectResponse + { $member->update(['confirmed_at' => now()]); return redirect()->route('member.index'); diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 34026941..bd097f35 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -15,13 +15,14 @@ use App\Nationality; use App\Payment\Subscription; use App\Region; use App\Setting\GeneralSettings; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Inertia\Response; class MemberController extends Controller { - public $filter = [ + public array $filter = [ 'ausstand' => false, 'bill_kind' => null, 'activity_id' => null, @@ -51,7 +52,8 @@ class MemberController extends Controller return \Inertia::render('member/VIndex', $payload); } - public function create(): Response { + public function create(): Response + { session()->put('menu', 'member'); session()->put('title', 'Mitglied erstellen'); @@ -76,13 +78,15 @@ class MemberController extends Controller ]); } - public function store(MemberRequest $request) { + public function store(MemberRequest $request): RedirectResponse + { $request->persistCreate(); return redirect()->route('member.index'); } - public function edit(Member $member, Request $request) { + public function edit(Member $member, Request $request): Response + { session()->put('menu', 'member'); session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten"); @@ -105,13 +109,15 @@ class MemberController extends Controller ]); } - public function update(Member $member, MemberRequest $request) { + public function update(Member $member, MemberRequest $request): RedirectResponse + { $request->persistUpdate($member); return redirect()->route('member.index'); } - public function destroy(Member $member) { + public function destroy(Member $member): RedirectResponse + { if ($member->has_nami) { DeleteJob::dispatch($member, auth()->user()); } diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index f87bee8f..beb08a34 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -66,7 +66,8 @@ class MemberRequest extends FormRequest } } - public function persistUpdate(Member $member) { + public function persistUpdate(Member $member): void + { $member->update($this->input()); if($this->input('has_nami') && $member->nami_id === null) { diff --git a/packages/laravel-nami b/packages/laravel-nami index a53cf6ab..3c64ccb6 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit a53cf6abd9add58f0a1a54c9c9f4b6cb41b01712 +Subproject commit 3c64ccb6ea27066983e9fcb3151f5e13782f2667