Lint
This commit is contained in:
parent
09e8ab1bcc
commit
d0b78d3120
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
|
|
|
@ -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([
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ class InitializeJob implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasProgress;
|
||||
|
||||
public $user;
|
||||
public NamiUser $user;
|
||||
|
||||
public function __construct(NamiUser $user)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
namespace App\Initialize;
|
||||
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
|
||||
class InitializeNationalities {
|
||||
|
||||
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->nationalities()->each(function($nationality) {
|
||||
\App\Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]);
|
||||
});
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a53cf6abd9add58f0a1a54c9c9f4b6cb41b01712
|
||||
Subproject commit 3c64ccb6ea27066983e9fcb3151f5e13782f2667
|
Loading…
Reference in New Issue