diff --git a/app/Course/Resources/CourseResource.php b/app/Course/Resources/CourseResource.php index 24c571d8..5e6bf88d 100644 --- a/app/Course/Resources/CourseResource.php +++ b/app/Course/Resources/CourseResource.php @@ -5,6 +5,9 @@ namespace App\Course\Resources; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin \App\Course\Models\CourseMember + */ class CourseResource extends JsonResource { /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d69cdbc6..7f0218b4 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -11,7 +11,7 @@ class Handler extends ExceptionHandler /** * A list of the exception types that are not reported. * - * @var array + * @var string[] */ protected $dontReport = [ // @@ -20,7 +20,7 @@ class Handler extends ExceptionHandler /** * A list of the inputs that are never flashed for validation exceptions. * - * @var array + * @var string[] */ protected $dontFlash = [ 'password', diff --git a/app/Http/Middleware/InertiaShareMiddleware.php b/app/Http/Middleware/InertiaShareMiddleware.php index 05eefee5..1035c7e3 100644 --- a/app/Http/Middleware/InertiaShareMiddleware.php +++ b/app/Http/Middleware/InertiaShareMiddleware.php @@ -15,7 +15,6 @@ class InertiaShareMiddleware * * @param \Illuminate\Http\Request $request * @param \Closure $next - * @param GeneralSettings $settings * @return mixed */ public function handle($request, Closure $next) diff --git a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php index 90f29de7..657a1d7e 100644 --- a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php +++ b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php @@ -30,10 +30,10 @@ class RedirectIfNotInitializedMiddleware } public function shouldRedirect() { - return !in_array(request()->route()->getName(), $this->dontRedirect) && auth()->check(); + return !request()->routeIs($this->dontRedirect) && auth()->check(); } public function initialized() { - return \App\Fee::get()->count() > 0; + return \App\Fee::count() > 0; } } diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index c5164381..d3689e5e 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -5,6 +5,9 @@ namespace App\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; use Storage; +/** + * @mixin \Zoomyboy\LaravelNami\NamiUser + */ class UserResource extends JsonResource { /** diff --git a/app/Http/Views/HomeView.php b/app/Http/Views/HomeView.php index 3c5da304..aa1f0326 100644 --- a/app/Http/Views/HomeView.php +++ b/app/Http/Views/HomeView.php @@ -12,7 +12,8 @@ use Illuminate\Http\Request; class HomeView { public function index(Request $request) { - $amount = Payment::whereNeedsPayment()->selectRaw('sum(subscriptions.amount) AS a')->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')->first()->a; + /** @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(); return [ @@ -20,7 +21,7 @@ class HomeView { 'payments' => [ 'users' => $members, 'all_users' => Member::count(), - 'amount' => number_format($amount / 100, 2, ',', '.').' €' + 'amount' => number_format($amount->a / 100, 2, ',', '.').' €' ], 'groups' => Member::select('subactivities.slug', 'subactivities.name')->selectRaw('COUNT(members.id) AS count')->join('memberships', 'memberships.member_id', 'members.id') ->join('activities', 'memberships.activity_id', 'activities.id') diff --git a/app/Http/Views/MemberTriesResource.php b/app/Http/Views/MemberTriesResource.php index cb3676c8..702eb57e 100644 --- a/app/Http/Views/MemberTriesResource.php +++ b/app/Http/Views/MemberTriesResource.php @@ -5,6 +5,9 @@ namespace App\Http\Views; use App\Member\MemberResource; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin \App\Member\Member + */ class MemberTriesResource extends MemberResource { /** diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index 740f3aad..f2ff24be 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -61,8 +61,8 @@ class MemberView { private function additional($member, $overwrites = []) { return (new MemberResource($member->load('payments'))) ->additional(array_merge([ - 'subscriptions' => Subscription::get()->pluck('name', 'id'), - 'statuses' => Status::get()->pluck('name', 'id'), + 'subscriptions' => Subscription::pluck('name', 'id'), + 'statuses' => Status::pluck('name', 'id'), ], $overwrites)); } diff --git a/app/Initialize/InitializeActivities.php b/app/Initialize/InitializeActivities.php index 05e316bb..2fdd2322 100644 --- a/app/Initialize/InitializeActivities.php +++ b/app/Initialize/InitializeActivities.php @@ -1,4 +1,4 @@ -api->subactivitiesOf($activity->nami_id)->each(function($group) use ($activity, &$groups) { + $this->api->subactivitiesOf($activity->nami_id)->each(function($group) use (&$groups) { $group = \App\Subactivity::updateOrCreate(['nami_id' => $group->id], [ 'nami_id' => $group->id, 'name' => $group->name, diff --git a/app/Initialize/InitializeCourses.php b/app/Initialize/InitializeCourses.php index 1ce23bcf..3e5e1fed 100644 --- a/app/Initialize/InitializeCourses.php +++ b/app/Initialize/InitializeCourses.php @@ -1,4 +1,4 @@ -bar = $bar; @@ -19,8 +19,10 @@ class InitializeCourses { public function handle(NamiUser $user): void { - $this->api->courses()->each(function($course) { - Course::create(['nami_id' => $course->id, 'name' => $course->name]); + $this->bar->task('Synchronisiere Kurse', function() { + $this->api->courses()->each(function($course) { + Course::create(['nami_id' => $course->id, 'name' => $course->name]); + }); }); } } diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index ef39e396..5c81ff72 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -47,7 +47,6 @@ class InitializeMembers { $m = Member::create([ 'firstname' => $member->firstname, 'lastname' => $member->lastname, - 'nickname' => $member->nickname, 'joined_at' => $member->joined_at, 'birthday' => $member->birthday, 'send_newspaper' => $member->send_newspaper, diff --git a/app/Member/CreateJob.php b/app/Member/CreateJob.php index 9b31d73a..0bdda919 100644 --- a/app/Member/CreateJob.php +++ b/app/Member/CreateJob.php @@ -37,13 +37,12 @@ class CreateJob implements ShouldQueue $this->member = Member::find($this->memberId); if ($this->member->hasNami) { - return false; + return; } $response = $this->user->api()->putMember([ 'firstname' => $this->member->firstname, 'lastname' => $this->member->lastname, - 'nickname' => $this->member->nickname, 'joined_at' => $this->member->joined_at, 'birthday' => $this->member->birthday, 'send_newspaper' => $this->member->send_newspaper, @@ -77,10 +76,10 @@ class CreateJob implements ShouldQueue $memberships = $this->member->getNamiMemberships($this->user->api()); foreach ($memberships as $membership) { $this->member->memberships()->create([ - 'activity_id' => Activity::nami($membership['activity_id'])->id, + 'activity_id' => Activity::nami($membership['activity_id'])->id, 'subactivity_id' => $membership['subactivity_id'] ? Subactivity::nami($membership['subactivity_id'])->id - : null, + : null, 'group_id' => Group::nami($membership['group_id'])->id, 'nami_id' => $membership['id'], 'created_at' => $membership['starts_at'], diff --git a/app/Member/DeleteJob.php b/app/Member/DeleteJob.php index 5b1be239..f37108f1 100644 --- a/app/Member/DeleteJob.php +++ b/app/Member/DeleteJob.php @@ -2,13 +2,13 @@ namespace App\Member; +use App\Confession; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Zoomyboy\LaravelNami\Nami; -use App\Confession; class DeleteJob implements ShouldQueue { @@ -34,7 +34,7 @@ class DeleteJob implements ShouldQueue $this->member = Member::find($this->memberId); if (!$this->member->hasNami) { - return false; + return; } Nami::login($this->user->mglnr)->deleteMember($this->member->nami_id); diff --git a/app/Member/Member.php b/app/Member/Member.php index bb86027d..8c297cf6 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -22,6 +22,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Notifications\Notifiable; use Zoomyboy\LaravelNami\Api; +/** + * @property string $subscription_name + * @property int $pending_payment + * @property bool $is_confirmed + * @property string $age_group_icon + * @property \Carbon\Carbon $try_created_at + */ class Member extends Model { use Notifiable; diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 6889f5f2..e92b0909 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -31,7 +31,7 @@ class MemberController extends Controller public function index(Request $request, GeneralSettings $settings): Response { session()->put('menu', 'member'); session()->put('title', 'Mitglieder'); - + $query = [ 'filter' => array_merge( $this->filter, @@ -46,7 +46,7 @@ class MemberController extends Controller ['href' => route('sendpayment.create'), 'label' => 'Rechnungen versenden', 'color' => 'info', 'icon' => 'envelope', 'show' => $settings->hasModule('bill')], ]; $payload['query'] = $query; - $payload['billKinds'] = BillKind::get()->pluck('name', 'id'); + $payload['billKinds'] = BillKind::pluck('name', 'id'); return \Inertia::render('member/Index', $payload); } @@ -60,15 +60,15 @@ class MemberController extends Controller return \Inertia::render('member/Form', [ 'activities' => $activities->pluck('name', 'id'), 'subactivities' => $activities->map(function(Activity $activity) { - return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id]; + return ['subactivities' => $activity->subactivities()->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), - 'billKinds' => BillKind::get()->pluck('name', 'id'), - 'genders' => Gender::get()->pluck('name', 'id'), - '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'), - 'subscriptions' => Subscription::get()->pluck('name', 'id'), + 'billKinds' => BillKind::pluck('name', 'id'), + 'genders' => Gender::pluck('name', 'id'), + 'countries' => Country::pluck('name', 'id'), + 'regions' => Region::where('is_null', false)->pluck('name', 'id'), + 'nationalities' => Nationality::pluck('name', 'id'), + 'confessions' => Confession::where('is_null', false)->pluck('name', 'id'), + 'subscriptions' => Subscription::pluck('name', 'id'), 'data' => [ 'country_id' => Country::default() ], @@ -93,13 +93,13 @@ class MemberController extends Controller 'subactivities' => $activities->map(function($activity) { return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), - 'billKinds' => BillKind::get()->pluck('name', 'id'), - 'genders' => Gender::get()->pluck('name', 'id'), - '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'), - 'subscriptions' => Subscription::get()->pluck('name', 'id'), + 'billKinds' => BillKind::pluck('name', 'id'), + 'genders' => Gender::pluck('name', 'id'), + 'countries' => Country::pluck('name', 'id'), + 'regions' => Region::where('is_null', false)->pluck('name', 'id'), + 'nationalities' => Nationality::pluck('name', 'id'), + 'confessions' => Confession::where('is_null', false)->pluck('name', 'id'), + 'subscriptions' => Subscription::pluck('name', 'id'), 'data' => new MemberResource($member), 'mode' => 'edit', ]); diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 15964c12..f87bee8f 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -2,13 +2,13 @@ namespace App\Member; -use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Rule; -use App\Group; -use Illuminate\Support\Str; use App\Activity; +use App\Group; +use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Str; +use Illuminate\Validation\Rule; class MemberRequest extends FormRequest { @@ -30,15 +30,15 @@ class MemberRequest extends FormRequest public function rules() { return [ - 'first_activity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'), - 'first_subactivity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'), + 'first_activity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'), + 'first_subactivity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'), 'subscription_id' => Rule::requiredIf(function() { if ($this->method() != 'POST') { return false; } - + if (!$this->input('first_activity_id')) { return true; } - + return Str::contains(Activity::findOrFail($this->input('first_activity_id'))->name, '€'); }), 'firstname' => 'required', diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 0fe45a79..dc9fa2ae 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -7,6 +7,9 @@ use App\Membership\MembershipResource; use App\Payment\PaymentResource; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin \App\Member\Member + */ class MemberResource extends JsonResource { /** diff --git a/app/Member/UpdateJob.php b/app/Member/UpdateJob.php index 5ccecb5e..af6ed943 100644 --- a/app/Member/UpdateJob.php +++ b/app/Member/UpdateJob.php @@ -2,13 +2,13 @@ namespace App\Member; +use App\Confession; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Zoomyboy\LaravelNami\Nami; -use App\Confession; class UpdateJob implements ShouldQueue { @@ -34,13 +34,12 @@ class UpdateJob implements ShouldQueue $this->member = Member::find($this->memberId); if (!$this->member->hasNami) { - return false; + return; } $response = Nami::login($this->user->mglnr)->putMember([ 'firstname' => $this->member->firstname, 'lastname' => $this->member->lastname, - 'nickname' => $this->member->nickname, 'joined_at' => $this->member->joined_at, 'birthday' => $this->member->birthday, 'send_newspaper' => $this->member->send_newspaper, diff --git a/app/Membership/MembershipResource.php b/app/Membership/MembershipResource.php index 8cd6d01d..7c4fa205 100644 --- a/app/Membership/MembershipResource.php +++ b/app/Membership/MembershipResource.php @@ -4,6 +4,9 @@ namespace App\Membership; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin \App\Member\Membership + */ class MembershipResource extends JsonResource { /** diff --git a/app/Payment/PaymentController.php b/app/Payment/PaymentController.php index 84cdca34..09d90e9e 100644 --- a/app/Payment/PaymentController.php +++ b/app/Payment/PaymentController.php @@ -14,7 +14,7 @@ class PaymentController extends Controller session()->put('menu', 'member'); session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); - $payload = app(MemberView::class)->index($request); + $payload = app(MemberView::class)->index($request, []); $payload['single'] = app(MemberView::class)->paymentIndex($member); return \Inertia::render('member/Index', $payload); @@ -34,7 +34,7 @@ class PaymentController extends Controller session()->put('menu', 'member'); session()->put('title', "Zahlungen für Mitglied {$member->fullname}"); - $payload = app(MemberView::class)->index($request); + $payload = app(MemberView::class)->index($request, []); $payload['single'] = app(MemberView::class)->paymentEdit($member, $payment); return \Inertia::render('member/Index', $payload); diff --git a/app/Payment/PaymentResource.php b/app/Payment/PaymentResource.php index 617888bd..6a9ea563 100644 --- a/app/Payment/PaymentResource.php +++ b/app/Payment/PaymentResource.php @@ -4,6 +4,9 @@ namespace App\Payment; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin Payment + */ class PaymentResource extends JsonResource { /** diff --git a/app/Payment/PaymentSendCommand.php b/app/Payment/PaymentSendCommand.php index 2b67fb32..8c4fa5ae 100644 --- a/app/Payment/PaymentSendCommand.php +++ b/app/Payment/PaymentSendCommand.php @@ -44,6 +44,8 @@ class PaymentSendCommand extends Command { $this->sendBills(); $this->sendRemembers(); + + return 0; } private function sendBills(): void diff --git a/app/Payment/Status.php b/app/Payment/Status.php index c017331e..b39070ae 100644 --- a/app/Payment/Status.php +++ b/app/Payment/Status.php @@ -21,7 +21,8 @@ class Status extends Model return static::where('is_bill', true)->where('is_remember', true)->first()->id; } - public function isAccepted() { + public function isAccepted(): bool + { return $this->is_bill === false && $this->is_remember === false; } diff --git a/app/Payment/Subscription.php b/app/Payment/Subscription.php index 345a1ea9..f573aaab 100644 --- a/app/Payment/Subscription.php +++ b/app/Payment/Subscription.php @@ -2,9 +2,10 @@ namespace App\Payment; +use App\Fee; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use App\Fee; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Subscription extends Model { @@ -12,7 +13,7 @@ class Subscription extends Model public $fillable = ['name', 'amount', 'fee_id']; - public function fee() { + public function fee(): BelongsTo { return $this->belongsTo(Fee::class); } } diff --git a/app/Payment/SubscriptionController.php b/app/Payment/SubscriptionController.php index cd26bf92..811fe35b 100644 --- a/app/Payment/SubscriptionController.php +++ b/app/Payment/SubscriptionController.php @@ -2,9 +2,9 @@ namespace App\Payment; +use App\Fee; use App\Http\Controllers\Controller; use Illuminate\Http\Request; -use App\Fee; class SubscriptionController extends Controller { @@ -23,7 +23,7 @@ class SubscriptionController extends Controller session()->put('title', 'Beitrag erstellen'); return \Inertia::render('subscription/Form', [ - 'fees' => Fee::get()->pluck('name', 'id'), + 'fees' => Fee::pluck('name', 'id'), 'mode' => 'create', 'data' => (object) [] ]); @@ -44,7 +44,7 @@ class SubscriptionController extends Controller session()->put('title', "Beitrag {$subscription->name} bearbeiten"); return \Inertia::render('subscription/Form', [ - 'fees' => Fee::get()->pluck('name', 'id'), + 'fees' => Fee::pluck('name', 'id'), 'mode' => 'edit', 'data' => new SubscriptionResource($subscription), ]); diff --git a/app/Payment/SubscriptionResource.php b/app/Payment/SubscriptionResource.php index 25f84450..adbb9780 100644 --- a/app/Payment/SubscriptionResource.php +++ b/app/Payment/SubscriptionResource.php @@ -4,6 +4,9 @@ namespace App\Payment; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @mixin Subscription + */ class SubscriptionResource extends JsonResource { /** diff --git a/app/Pdf/BillType.php b/app/Pdf/BillType.php index 8c7c03ab..a026f060 100644 --- a/app/Pdf/BillType.php +++ b/app/Pdf/BillType.php @@ -10,12 +10,6 @@ class BillType extends Repository implements PdfRepository { public string $filename; - public Collection $pages; - - public function __construct(Collection $pages) - { - $this->pages = $pages; - } public function getPayments(Member $member): Collection { @@ -97,7 +91,7 @@ class BillType extends Repository implements PdfRepository return "Mitgliedsbeitrag für {$this->getFamilyName($page)}"; } - public function allLabel(): string + public function allLabel(): string { return 'Rechnungen versenden'; } @@ -107,7 +101,7 @@ class BillType extends Repository implements PdfRepository * * @return array */ - public function getDescription(): array + public function getDescription(): array { return [ 'Diese Funktion erstellt ein PDF mit allen noch nicht versendenden Rechnungen bei den Mitgliedern die Post als Versandweg haben.', diff --git a/app/Pdf/PdfRepository.php b/app/Pdf/PdfRepository.php index 5426c3a6..6f0a9044 100644 --- a/app/Pdf/PdfRepository.php +++ b/app/Pdf/PdfRepository.php @@ -5,6 +5,7 @@ namespace App\Pdf; use App\Member\Member; use App\Payment\Payment; use Carbon\Carbon; +use Generator; use Illuminate\Support\Collection; interface PdfRepository @@ -50,4 +51,6 @@ interface PdfRepository public function getMailSubject(): string; + public function allPayments(): Generator; + } diff --git a/app/Pdf/RememberType.php b/app/Pdf/RememberType.php index e5662090..2dd5c38d 100644 --- a/app/Pdf/RememberType.php +++ b/app/Pdf/RememberType.php @@ -10,12 +10,6 @@ class RememberType extends Repository implements PdfRepository { public string $filename; - public Collection $pages; - - public function __construct(Collection $pages) - { - $this->pages = $pages; - } public function getPayments(Member $member): Collection { diff --git a/app/Pdf/Repository.php b/app/Pdf/Repository.php index a019107b..663b5452 100644 --- a/app/Pdf/Repository.php +++ b/app/Pdf/Repository.php @@ -5,10 +5,20 @@ namespace App\Pdf; use App\Member\Member; use Carbon\Carbon; use Generator; +use Illuminate\Support\Collection; abstract class Repository { + abstract public function getPayments(Member $member): Collection; + + public Collection $pages; + + public function __construct(Collection $pages) + { + $this->pages = $pages; + } + public function number(int $number): string { return number_format($number / 100, 2, '.', ''); diff --git a/phpstan.neon b/phpstan.neon index d38b8062..76106382 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,6 +10,8 @@ parameters: level: 5 ignoreErrors: - - '#Unsafe usage of new static#' + - '#Call to an undefined method Illuminate\\Contracts\\Auth\\Authenticatable::api\(\)#' + - '#Call to an undefined method Illuminate\\Contracts\\Auth\\Authenticatable::getNamiGroupId\(\)#' + - '#Illuminate\\Contracts\\Auth\\Authenticatable\|null given#' checkMissingIterableValueType: false