diff --git a/app/Activity.php b/app/Activity.php index 71cd143d..483283d6 100644 --- a/app/Activity.php +++ b/app/Activity.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Activity extends Model { - use HasFactory; use HasNamiField; use Sluggable; @@ -19,7 +18,7 @@ class Activity extends Model public $timestamps = false; public $casts = [ - 'nami_id' => 'integer' + 'nami_id' => 'integer', ]; public function sluggable(): array @@ -31,8 +30,8 @@ class Activity extends Model ]; } - public function subactivities(): BelongsToMany { + public function subactivities(): BelongsToMany + { return $this->belongsToMany(Subactivity::class); } - } diff --git a/app/Confession.php b/app/Confession.php index 2dbdd20c..8cf1259d 100644 --- a/app/Confession.php +++ b/app/Confession.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model; class Confession extends Model { - use HasFactory; public $fillable = ['name', 'nami_id', 'is_null']; diff --git a/app/Console/Commands/NamiInitializeCommand.php b/app/Console/Commands/NamiInitializeCommand.php index 7079add7..f8869284 100644 --- a/app/Console/Commands/NamiInitializeCommand.php +++ b/app/Console/Commands/NamiInitializeCommand.php @@ -4,7 +4,6 @@ namespace App\Console\Commands; use App\Initialize\Initializer; use Illuminate\Console\Command; -use Zoomyboy\LaravelNami\Nami; use Zoomyboy\LaravelNami\NamiException; class NamiInitializeCommand extends Command @@ -44,6 +43,7 @@ class NamiInitializeCommand extends Command app(Initializer::class)->run(); } catch (NamiException $e) { $e->outputToConsole($this); + return 1; } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3dac3102..71120fcf 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,14 +13,13 @@ class Kernel extends ConsoleKernel * * @var array */ - protected $commands = [ + protected $commands = [ PaymentSendCommand::class, ]; /** * Define the application's command schedule. * - * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) diff --git a/app/Country.php b/app/Country.php index 8598def9..99703da4 100644 --- a/app/Country.php +++ b/app/Country.php @@ -13,7 +13,8 @@ class Country extends Model public $fillable = ['name', 'nami_id']; - public static function default(): int { + public static function default(): int + { return self::whereName('Deutschland')->firstOrFail()->id; } diff --git a/app/Course/Controllers/CourseController.php b/app/Course/Controllers/CourseController.php index 8c5276be..c434adfa 100644 --- a/app/Course/Controllers/CourseController.php +++ b/app/Course/Controllers/CourseController.php @@ -10,7 +10,6 @@ use App\Http\Controllers\Controller; use App\Member\Member; use App\Setting\NamiSettings; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; class CourseController extends Controller { diff --git a/app/Course/Requests/DestroyRequest.php b/app/Course/Requests/DestroyRequest.php index 744d600b..336d1dd6 100644 --- a/app/Course/Requests/DestroyRequest.php +++ b/app/Course/Requests/DestroyRequest.php @@ -2,14 +2,10 @@ namespace App\Course\Requests; -use App\Course\Models\Course; use App\Course\Models\CourseMember; use App\Member\Member; use App\Setting\NamiSettings; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Arr; -use Illuminate\Validation\ValidationException; -use Zoomyboy\LaravelNami\NamiException; class DestroyRequest extends FormRequest { diff --git a/app/Course/Requests/StoreRequest.php b/app/Course/Requests/StoreRequest.php index 5434fd8b..57d3c1a7 100644 --- a/app/Course/Requests/StoreRequest.php +++ b/app/Course/Requests/StoreRequest.php @@ -6,14 +6,9 @@ use App\Course\Models\Course; use App\Member\Member; use App\Setting\NamiSettings; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Arr; -use Illuminate\Validation\ValidationException; -use Zoomyboy\LaravelNami\Nami; -use Zoomyboy\LaravelNami\NamiException; class StoreRequest extends FormRequest { - /** * Determine if the user is authorized to make this request. * @@ -51,5 +46,4 @@ class StoreRequest extends FormRequest $member->courses()->create($this->safe()->collect()->put('nami_id', $namiId)->toArray()); } - } diff --git a/app/Course/Requests/UpdateRequest.php b/app/Course/Requests/UpdateRequest.php index e179e334..82d87c52 100644 --- a/app/Course/Requests/UpdateRequest.php +++ b/app/Course/Requests/UpdateRequest.php @@ -7,9 +7,6 @@ use App\Course\Models\CourseMember; use App\Member\Member; use App\Setting\NamiSettings; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Arr; -use Illuminate\Validation\ValidationException; -use Zoomyboy\LaravelNami\NamiException; class UpdateRequest extends FormRequest { diff --git a/app/Course/Resources/CourseResource.php b/app/Course/Resources/CourseResource.php index 5e6bf88d..9a42d8fb 100644 --- a/app/Course/Resources/CourseResource.php +++ b/app/Course/Resources/CourseResource.php @@ -13,7 +13,8 @@ class CourseResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable */ public function toArray($request) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1300def6..d9aa7d89 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -6,7 +6,6 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Validation\ValidationException; use Throwable; use Zoomyboy\LaravelNami\LoginException; -use Zoomyboy\LaravelNami\NamiException; class Handler extends ExceptionHandler { @@ -16,7 +15,6 @@ class Handler extends ExceptionHandler * @var string[] */ protected $dontReport = [ - // ]; /** @@ -32,7 +30,6 @@ class Handler extends ExceptionHandler /** * Report or log an exception. * - * @param \Throwable $exception * @return void * * @throws \Exception @@ -45,8 +42,8 @@ class Handler extends ExceptionHandler /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request - * @param \Throwable $exception + * @param \Illuminate\Http\Request $request + * * @return \Symfony\Component\HttpFoundation\Response * * @throws \Throwable diff --git a/app/Fee.php b/app/Fee.php index 631453d5..fdaa8802 100644 --- a/app/Fee.php +++ b/app/Fee.php @@ -2,7 +2,6 @@ namespace App; -use App\Member\Member; use App\Payment\Subscription; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; diff --git a/app/Gender.php b/app/Gender.php index be09e6b7..8eab60cd 100644 --- a/app/Gender.php +++ b/app/Gender.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Model; class Gender extends Model { - use HasNamiField; public $fillable = ['name', 'nami_id']; diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index c320716a..e184afa7 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -39,8 +39,8 @@ class LoginController extends Controller $this->middleware('guest')->except('logout'); } - public function showLoginForm(): Response { + public function showLoginForm(): Response + { return \Inertia::render('VLogin'); } - } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c6a6de67..edb9c4a4 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -44,7 +44,6 @@ class RegisterController extends Controller /** * Get a validator for an incoming registration request. * - * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) @@ -59,7 +58,6 @@ class RegisterController extends Controller /** * Create a new user instance after a valid registration. * - * @param array $data * @return \App\User */ protected function create(array $data) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index e749914f..345847e2 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController; abstract class Controller extends BaseController { - use AuthorizesRequests, DispatchesJobs, ValidatesRequests; + use AuthorizesRequests; + use DispatchesJobs; + use ValidatesRequests; } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 841e81ef..92eb27ef 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -37,7 +37,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\InertiaShareMiddleware::class, - \App\Http\Middleware\RedirectIfNotInitializedMiddleware::class + \App\Http\Middleware\RedirectIfNotInitializedMiddleware::class, ], 'api' => [ diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 704089a7..2306b821 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -9,12 +9,13 @@ class Authenticate extends Middleware /** * Get the path the user should be redirected to when they are not authenticated. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return string|null */ protected function redirectTo($request) { - if (! $request->expectsJson()) { + if (!$request->expectsJson()) { return route('login'); } } diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php index 35b9824b..cc84e35e 100644 --- a/app/Http/Middleware/CheckForMaintenanceMode.php +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -12,6 +12,5 @@ class CheckForMaintenanceMode extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 033136ad..50d0fe79 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -12,6 +12,5 @@ class EncryptCookies extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/Http/Middleware/InertiaShareMiddleware.php b/app/Http/Middleware/InertiaShareMiddleware.php index 1035c7e3..f82998c4 100644 --- a/app/Http/Middleware/InertiaShareMiddleware.php +++ b/app/Http/Middleware/InertiaShareMiddleware.php @@ -9,12 +9,11 @@ use Session; class InertiaShareMiddleware { - /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Illuminate\Http\Request $request + * * @return mixed */ public function handle($request, Closure $next) @@ -23,7 +22,7 @@ class InertiaShareMiddleware 'auth' => ['user' => auth()->check() ? new UserResource(auth()->user()) : null], 'search' => $request->query('search', ''), 'flash' => session()->get('flash'), - 'menu' => function() { + 'menu' => function () { return session()->get('menu'); }, 'errors' => function () { @@ -31,12 +30,12 @@ class InertiaShareMiddleware ? Session::get('errors')->getBag('default')->getMessages() : (object) []; }, - 'title' => function() { + 'title' => function () { return session()->get('title', ''); }, 'settings' => [ 'modules' => app(GeneralSettings::class)->modules, - ] + ], ]); $response = $next($request); diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 2395ddcc..8e75e5fb 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -11,9 +11,9 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Illuminate\Http\Request $request + * @param string|null $guard + * * @return mixed */ public function handle($request, Closure $next, $guard = null) diff --git a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php index 2c3fc309..e5e981f0 100644 --- a/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php +++ b/app/Http/Middleware/RedirectIfNotInitializedMiddleware.php @@ -6,19 +6,18 @@ use Closure; class RedirectIfNotInitializedMiddleware { - public array $dontRedirect = ['initialize.index', 'initialize.store']; /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Illuminate\Http\Request $request + * * @return mixed */ public function handle($request, Closure $next) { - if(!$this->shouldRedirect()) { + if (!$this->shouldRedirect()) { return $next($request); } diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 0c13b854..4c029cf3 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -12,6 +12,5 @@ class VerifyCsrfToken extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index f2b9b65d..e00f6504 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -13,7 +13,8 @@ class UserResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) @@ -22,8 +23,8 @@ class UserResource extends JsonResource 'name' => $this->name, 'email' => $this->email, 'avatar' => [ - 'src' => Storage::url('avatar.png') - ] + 'src' => Storage::url('avatar.png'), + ], ]; } } diff --git a/app/Http/Views/HomeView.php b/app/Http/Views/HomeView.php index fc0635c0..ef6642f9 100644 --- a/app/Http/Views/HomeView.php +++ b/app/Http/Views/HomeView.php @@ -3,14 +3,11 @@ namespace App\Http\Views; use App\Member\Member; -use App\Member\MemberResource; use App\Payment\Payment; -use App\Payment\PaymentResource; -use App\Payment\Status; -use App\Payment\Subscription; use Illuminate\Http\Request; -class HomeView { +class HomeView +{ public function index(Request $request): array { /** @var object{a: string} */ @@ -22,7 +19,7 @@ class HomeView { 'payments' => [ 'users' => $members, 'all_users' => Member::count(), - 'amount' => number_format($amount->a / 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') @@ -33,8 +30,7 @@ class HomeView { ->orderBy('subactivities.id') ->get(), 'ending_tries' => MemberTriesResource::collection(Member::endingTries()->get()), - ] + ], ]; } - } diff --git a/app/Http/Views/MemberTriesResource.php b/app/Http/Views/MemberTriesResource.php index 702eb57e..06194cc0 100644 --- a/app/Http/Views/MemberTriesResource.php +++ b/app/Http/Views/MemberTriesResource.php @@ -3,7 +3,6 @@ namespace App\Http\Views; use App\Member\MemberResource; -use Illuminate\Http\Resources\Json\JsonResource; /** * @mixin \App\Member\Member @@ -13,7 +12,8 @@ class MemberTriesResource extends MemberResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index effbc955..2de82bc7 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -14,7 +14,8 @@ use App\Payment\Subscription; use App\Subactivity; use Illuminate\Http\Request; -class MemberView { +class MemberView +{ public function index(Request $request, array $filter): array { $activities = Activity::with('subactivities')->get(); @@ -29,13 +30,13 @@ class MemberView { ), 'filterActivities' => Activity::where('is_filterable', true)->pluck('name', 'id'), 'filterSubactivities' => Subactivity::where('is_filterable', true)->pluck('name', 'id'), - 'toolbar' => [ ['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus'] ], + 'toolbar' => [['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus']], 'paymentDefaults' => ['nr' => date('Y')], 'subscriptions' => Subscription::pluck('name', 'id'), 'statuses' => Status::pluck('name', 'id'), 'activities' => $activities->pluck('name', 'id'), 'courses' => Course::pluck('name', 'id'), - 'subactivities' => $activities->map(function(Activity $activity) { + 'subactivities' => $activities->map(function (Activity $activity) { return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), ]; @@ -45,7 +46,7 @@ class MemberView { { return $this->additional($member, [ 'model' => new PaymentResource($payment), - 'links' => [ ['label' => 'Zurück', 'href' => route('member.payment.index', ['member' => $member]) ] ], + 'links' => [['label' => 'Zurück', 'href' => route('member.payment.index', ['member' => $member])]], 'mode' => 'edit', ]); } @@ -55,7 +56,7 @@ class MemberView { return $this->additional($member, [ 'model' => null, 'links' => [ - ['icon' => 'plus', 'href' => route('member.payment.create', ['member' => $member]) ], + ['icon' => 'plus', 'href' => route('member.payment.create', ['member' => $member])], ], 'payment_links' => app(ActionFactory::class)->forMember($member), 'mode' => 'index', @@ -70,5 +71,4 @@ class MemberView { 'statuses' => Status::pluck('name', 'id'), ], $overwrites)); } - } diff --git a/app/Initialize/ActivityCreator.php b/app/Initialize/ActivityCreator.php index d773dbe9..4a1a6d09 100644 --- a/app/Initialize/ActivityCreator.php +++ b/app/Initialize/ActivityCreator.php @@ -4,8 +4,8 @@ namespace App\Initialize; use Zoomyboy\LaravelNami\Api; -class ActivityCreator { - +class ActivityCreator +{ private array $tries = [ 'Schnuppermitgliedschaft', ]; @@ -17,8 +17,8 @@ class ActivityCreator { public function createFor(Api $api, int $groupId): void { - $api->activities($groupId)->each(function($activity) use ($api) { - $activity = \App\Activity::updateOrCreate(['nami_id' => $activity->id], [ + $api->activities($groupId)->each(function ($activity) use ($api) { + $activity = \App\Activity::updateOrCreate(['nami_id' => $activity->id], [ 'nami_id' => $activity->id, 'name' => $activity->name, 'is_try' => in_array($activity->name, $this->tries), @@ -26,7 +26,7 @@ class ActivityCreator { ]); $groups = []; - $api->subactivitiesOf($activity->nami_id)->each(function($group) use (&$groups) { + $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, @@ -36,6 +36,4 @@ class ActivityCreator { $activity->subactivities()->sync($groups); }); } - } - diff --git a/app/Initialize/InitializeActivities.php b/app/Initialize/InitializeActivities.php index 0717d246..fc7601aa 100644 --- a/app/Initialize/InitializeActivities.php +++ b/app/Initialize/InitializeActivities.php @@ -4,11 +4,12 @@ namespace App\Initialize; use Zoomyboy\LaravelNami\Api; -class InitializeActivities { - +class InitializeActivities +{ private Api $api; - public function __construct(Api $api) { + public function __construct(Api $api) + { $this->api = $api; } diff --git a/app/Initialize/InitializeConfessions.php b/app/Initialize/InitializeConfessions.php index 878da3ec..fd32488d 100644 --- a/app/Initialize/InitializeConfessions.php +++ b/app/Initialize/InitializeConfessions.php @@ -1,22 +1,23 @@ -api = $api; } public function handle(): void { - $this->api->confessions()->each(function($confession) { + $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/InitializeController.php b/app/Initialize/InitializeController.php index fbb2097b..b95764fc 100644 --- a/app/Initialize/InitializeController.php +++ b/app/Initialize/InitializeController.php @@ -4,7 +4,6 @@ namespace App\Initialize; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; use Inertia\Response; class InitializeController extends Controller diff --git a/app/Initialize/InitializeCountries.php b/app/Initialize/InitializeCountries.php index 63ebcd98..e7a5785a 100644 --- a/app/Initialize/InitializeCountries.php +++ b/app/Initialize/InitializeCountries.php @@ -4,17 +4,18 @@ namespace App\Initialize; use Zoomyboy\LaravelNami\Api; -class InitializeCountries { - +class InitializeCountries +{ private Api $api; - public function __construct(Api $api) { + public function __construct(Api $api) + { $this->api = $api; } public function handle(): void { - $this->api->countries()->each(function($country) { + $this->api->countries()->each(function ($country) { \App\Country::create(['nami_id' => $country->id, 'name' => $country->name]); }); } diff --git a/app/Initialize/InitializeCourses.php b/app/Initialize/InitializeCourses.php index b69ce916..137feb49 100644 --- a/app/Initialize/InitializeCourses.php +++ b/app/Initialize/InitializeCourses.php @@ -5,17 +5,18 @@ namespace App\Initialize; use App\Course\Models\Course; use Zoomyboy\LaravelNami\Api; -class InitializeCourses { - +class InitializeCourses +{ private Api $api; - public function __construct(Api $api) { + public function __construct(Api $api) + { $this->api = $api; } public function handle(): void { - $this->api->courses()->each(function($course) { + $this->api->courses()->each(function ($course) { Course::create(['nami_id' => $course->id, 'name' => $course->name]); }); } diff --git a/app/Initialize/InitializeFees.php b/app/Initialize/InitializeFees.php index 2ac55833..d711d457 100644 --- a/app/Initialize/InitializeFees.php +++ b/app/Initialize/InitializeFees.php @@ -1,22 +1,23 @@ -api = $api; } public function handle(): void { $group = $this->api->groups()->first()->id; - $this->api->feesOf($group)->each(function($fee) { + $this->api->feesOf($group)->each(function ($fee) { Fee::create(['nami_id' => $fee->id, 'name' => $fee->name]) ->subscriptions()->create([ 'name' => $fee->name, diff --git a/app/Initialize/InitializeGenders.php b/app/Initialize/InitializeGenders.php index d81b376e..607ad55c 100644 --- a/app/Initialize/InitializeGenders.php +++ b/app/Initialize/InitializeGenders.php @@ -1,20 +1,21 @@ -api = $api; } public function handle(): void { - $this->api->genders()->each(function($gender) { + $this->api->genders()->each(function ($gender) { \App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->name]); }); } diff --git a/app/Initialize/InitializeGroups.php b/app/Initialize/InitializeGroups.php index 7a791c3a..3164017e 100644 --- a/app/Initialize/InitializeGroups.php +++ b/app/Initialize/InitializeGroups.php @@ -1,21 +1,22 @@ -api = $api; } public function handle(): void { - $this->api->groups()->each(function($group) { + $this->api->groups()->each(function ($group) { $parent = Group::updateOrCreate(['nami_id' => $group->id], ['nami_id' => $group->id, 'name' => $group->name]); $this->api->subgroupsOf($group->id)->each(function ($subgroup) use ($parent) { diff --git a/app/Initialize/InitializeJob.php b/app/Initialize/InitializeJob.php index ba76b5ea..3b06448f 100644 --- a/app/Initialize/InitializeJob.php +++ b/app/Initialize/InitializeJob.php @@ -2,7 +2,6 @@ namespace App\Initialize; -use App\Member; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -11,7 +10,10 @@ use Illuminate\Queue\SerializesModels; class InitializeJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; /** * Execute the job. diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index 8ef03ee1..a4557bfc 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -13,20 +13,19 @@ use App\Member\Member; use App\Nationality; use App\Region; use App\Subactivity; -use Carbon\Carbon; use Illuminate\Database\Eloquent\ModelNotFoundException; use Zoomyboy\LaravelNami\Api; use Zoomyboy\LaravelNami\Data\MembershipEntry; use Zoomyboy\LaravelNami\Exceptions\RightException; use Zoomyboy\LaravelNami\Member as NamiMember; -use Zoomyboy\LaravelNami\Membership as NamiMembership; use Zoomyboy\LaravelNami\NamiException; -class InitializeMembers { - +class InitializeMembers +{ private Api $api; - public function __construct(Api $api) { + public function __construct(Api $api) + { $this->api = $api; } @@ -44,7 +43,7 @@ class InitializeMembers { { $allMembers = collect([]); - $this->api->search([])->each(function(NamiMember $member): void { + $this->api->search([])->each(function (NamiMember $member): void { $member = NamiMember::fromNami($this->api->member($member->group_id, $member->id)); if (!$member->joined_at) { return; @@ -90,12 +89,11 @@ class InitializeMembers { ]); } } catch (RightException $e) { - } try { foreach ($this->api->membershipsOf($member->id) as $membership) { - if ($membership->endsAt !== null) { + if (null !== $membership->endsAt) { continue; } try { @@ -115,7 +113,6 @@ class InitializeMembers { ]); } } catch (RightException $e) { - } } catch (ModelNotFoundException $e) { dd($e->getMessage(), $member); @@ -137,13 +134,14 @@ class InitializeMembers { $subactivityId = $membership->subactivityId ? Subactivity::where('nami_id', $membership->subactivityId)->firstOrFail()->id : null; + return [$activityId, $subactivityId, $group->id]; } catch (ModelNotFoundException $e) { return [null, null, null]; } } - if ($membershipEntry->subactivity === null) { + if (null === $membershipEntry->subactivity) { $subactivityId = null; } else { $subactivityId = Subactivity::where('name', $membershipEntry->subactivity)->firstOrFail()->id; @@ -160,7 +158,7 @@ class InitializeMembers { if (!Group::where('name', $membershipEntry->group)->exists()) { return true; } - if (preg_match('/\(([0-9]+)\)/', $membershipEntry->activity, $activityMatches) !== 1) { + if (1 !== preg_match('/\(([0-9]+)\)/', $membershipEntry->activity, $activityMatches)) { throw new NamiException("ID in taetigkeit string not found: {$membershipEntry->activity}"); } @@ -168,7 +166,7 @@ class InitializeMembers { return true; } - if ($membershipEntry->subactivity === null) { + if (null === $membershipEntry->subactivity) { return false; } diff --git a/app/Initialize/InitializeNationalities.php b/app/Initialize/InitializeNationalities.php index 07077205..e8321707 100644 --- a/app/Initialize/InitializeNationalities.php +++ b/app/Initialize/InitializeNationalities.php @@ -5,17 +5,18 @@ namespace App\Initialize; use App\Nationality; use Zoomyboy\LaravelNami\Api; -class InitializeNationalities { - +class InitializeNationalities +{ private Api $api; - public function __construct(Api $api) { + public function __construct(Api $api) + { $this->api = $api; } public function handle(Api $api): void { - $this->api->nationalities()->each(function($nationality) { + $this->api->nationalities()->each(function ($nationality) { Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]); }); } diff --git a/app/Initialize/InitializeRegions.php b/app/Initialize/InitializeRegions.php index 06496bee..c566be38 100644 --- a/app/Initialize/InitializeRegions.php +++ b/app/Initialize/InitializeRegions.php @@ -1,21 +1,22 @@ -api = $api; } public function handle(): void { - $this->api->regions()->each(function($region) { + $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/Initialize/Initializer.php b/app/Initialize/Initializer.php index 8effcb38..3123592b 100644 --- a/app/Initialize/Initializer.php +++ b/app/Initialize/Initializer.php @@ -3,10 +3,9 @@ namespace App\Initialize; use App\Setting\NamiSettings; -use Zoomyboy\LaravelNami\Api; - -class Initializer { +class Initializer +{ public NamiSettings $settings; public array $initializers = [ InitializeNationalities::class, @@ -25,10 +24,10 @@ class Initializer { $this->settings = $settings; } - public function run(): void { + public function run(): void + { foreach ($this->initializers as $initializer) { app($initializer)->handle($this->settings->login()); } } - } diff --git a/app/Member/CreateJob.php b/app/Member/CreateJob.php index b03ca2f3..76deb428 100644 --- a/app/Member/CreateJob.php +++ b/app/Member/CreateJob.php @@ -15,7 +15,10 @@ use Zoomyboy\LaravelNami\Nami; class CreateJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public int $memberId; public Member $member; @@ -67,7 +70,7 @@ class CreateJob implements ShouldQueue 'first_activity_id' => $this->member->firstActivity->nami_id, 'first_subactivity_id' => $this->member->firstSubactivity->nami_id, ]); - Member::withoutEvents(function() use ($response) { + Member::withoutEvents(function () use ($response) { $version = Nami::login($this->user->mglnr)->member($this->member->group->nami_id, $response['id'])['version']; $this->member->update(['version' => $version, 'nami_id' => $response['id']]); }); @@ -84,6 +87,5 @@ class CreateJob implements ShouldQueue 'created_at' => $membership['starts_at'], ]); } - } } diff --git a/app/Member/DeleteJob.php b/app/Member/DeleteJob.php index 3870c084..ddd040d5 100644 --- a/app/Member/DeleteJob.php +++ b/app/Member/DeleteJob.php @@ -2,17 +2,18 @@ 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; class DeleteJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public int $memberId; public Member $member; @@ -38,7 +39,7 @@ class DeleteJob implements ShouldQueue $setting->login()->deleteMember($this->member->nami_id); - Member::withoutEvents(function() { + Member::withoutEvents(function () { $this->member->update(['nami_id' => null]); }); } diff --git a/app/Member/Member.php b/app/Member/Member.php index 123a22f9..2363f4e9 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -18,16 +18,15 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\BelongsToMany; 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 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 @@ -51,8 +50,12 @@ class Member extends Model 'is_confirmed' => 'boolean', ]; - public function scopeSearch(Builder $q, ?string $text): Builder { - if (is_null($text)) { return $q; } + public function scopeSearch(Builder $q, ?string $text): Builder + { + if (is_null($text)) { + return $q; + } + return $q->where('firstname', 'LIKE', '%'.$text.'%') ->orWhere('lastname', 'LIKE', '%'.$text.'%') ->orWhere('address', 'LIKE', '%'.$text.'%') @@ -76,19 +79,23 @@ class Member extends Model } //----------------------------------- Getters ----------------------------------- - public function getFullnameAttribute(): string { + public function getFullnameAttribute(): string + { return $this->firstname.' '.$this->lastname; } - public function getHasNamiAttribute(): bool { - return $this->nami_id !== null; + public function getHasNamiAttribute(): bool + { + return null !== $this->nami_id; } - public function getNamiMemberships(Api $api): array { + public function getNamiMemberships(Api $api): array + { return $api->group($this->group->nami_id)->member($this->nami_id)->memberships()->toArray(); } - public function getNamiFeeId(): ?int { + public function getNamiFeeId(): ?int + { if (!$this->subscription) { return null; } @@ -164,70 +171,79 @@ class Member extends Model public static function booted() { - static::deleting(function(self $model): void { + static::deleting(function (self $model): void { $model->payments->each->delete(); }); } // ---------------------------------- Scopes ----------------------------------- - public function scopeWithIsConfirmed(Builder $q): Builder { + public function scopeWithIsConfirmed(Builder $q): Builder + { return $q->selectSub('DATEDIFF(NOW(), IFNULL(confirmed_at, DATE_SUB(NOW(), INTERVAL 3 YEAR))) < 712', 'is_confirmed'); } - public function scopeWithSubscriptionName(Builder $q): Builder { + public function scopeWithSubscriptionName(Builder $q): Builder + { return $q->addSelect([ - 'subscription_name' => Subscription::select('name')->whereColumn('subscriptions.id', 'members.subscription_id')->limit(1) + 'subscription_name' => Subscription::select('name')->whereColumn('subscriptions.id', 'members.subscription_id')->limit(1), ]); } - public function scopeWithPendingPayment(Builder $q): Builder { + public function scopeWithPendingPayment(Builder $q): Builder + { return $q->addSelect([ 'pending_payment' => Payment::selectRaw('SUM(subscriptions.amount)') ->whereColumn('payments.member_id', 'members.id') ->whereNeedsPayment() - ->join('subscriptions', 'subscriptions.id', 'payments.subscription_id') + ->join('subscriptions', 'subscriptions.id', 'payments.subscription_id'), ]); } - public function scopeWithAgeGroup(Builder $q): Builder { + public function scopeWithAgeGroup(Builder $q): Builder + { return $q->addSelect([ 'age_group_icon' => Subactivity::select('slug') ->join('memberships', 'memberships.subactivity_id', 'subactivities.id') ->where('subactivities.is_age_group', true) ->whereColumn('memberships.member_id', 'members.id') - ->limit(1) + ->limit(1), ]); } - public function scopeWhereHasPendingPayment(Builder $q): Builder { - return $q->whereHas('payments', function(Builder $q): void { + public function scopeWhereHasPendingPayment(Builder $q): Builder + { + return $q->whereHas('payments', function (Builder $q): void { $q->whereNeedsPayment(); }); } - public function scopeWhereAusstand(Builder $q): Builder { - return $q->whereHas('payments', function($q) { + public function scopeWhereAusstand(Builder $q): Builder + { + return $q->whereHas('payments', function ($q) { return $q->whereHas('status', fn ($q) => $q->where('is_remember', true)); }); } - public function scopePayable(Builder $q): Builder { + public function scopePayable(Builder $q): Builder + { return $q->where('bill_kind_id', '!=', null)->where('subscription_id', '!=', null); } - public function scopeWhereNoPayment(Builder $q, int $year): Builder { - return $q->whereDoesntHave('payments', function(Builder $q) use ($year) { + public function scopeWhereNoPayment(Builder $q, int $year): Builder + { + return $q->whereDoesntHave('payments', function (Builder $q) use ($year) { $q->where('nr', '=', $year); }); } - public function scopeForDashboard(Builder $q): Builder { + public function scopeForDashboard(Builder $q): Builder + { return $q->selectRaw('SUM(id)'); } public function scopeFilter(Builder $q, array $filter): Builder { - if (data_get($filter, 'ausstand', false) === true) { + if (true === data_get($filter, 'ausstand', false)) { $q->whereAusstand(); } if (data_get($filter, 'bill_kind', false)) { @@ -256,8 +272,7 @@ class Member extends Model 'try_created_at' => Membership::select('created_at') ->whereColumn('memberships.member_id', 'members.id') ->join('activities', 'activities.id', 'memberships.activity_id') - ->where('activities.is_try', true) + ->where('activities.is_try', true), ]); } - } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index bd097f35..c270c8f9 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -7,10 +7,8 @@ use App\Bill\BillKind; use App\Confession; use App\Country; use App\Gender; -use App\Group; use App\Http\Controllers\Controller; use App\Http\Views\MemberView; -use App\Member\DeleteJob; use App\Nationality; use App\Payment\Subscription; use App\Region; @@ -21,7 +19,6 @@ use Inertia\Response; class MemberController extends Controller { - public array $filter = [ 'ausstand' => false, 'bill_kind' => null, @@ -29,7 +26,8 @@ class MemberController extends Controller 'subactivity_id' => null, ]; - public function index(Request $request, GeneralSettings $settings): Response { + public function index(Request $request, GeneralSettings $settings): Response + { session()->put('menu', 'member'); session()->put('title', 'Mitglieder'); @@ -61,7 +59,7 @@ class MemberController extends Controller return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), - 'subactivities' => $activities->map(function(Activity $activity) { + 'subactivities' => $activities->map(function (Activity $activity) { return ['subactivities' => $activity->subactivities()->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), 'billKinds' => BillKind::pluck('name', 'id'), @@ -72,7 +70,7 @@ class MemberController extends Controller 'confessions' => Confession::where('is_null', false)->pluck('name', 'id'), 'subscriptions' => Subscription::pluck('name', 'id'), 'data' => [ - 'country_id' => Country::default() + 'country_id' => Country::default(), ], 'mode' => 'create', ]); @@ -94,7 +92,7 @@ class MemberController extends Controller return \Inertia::render('member/VForm', [ 'activities' => $activities->pluck('name', 'id'), - 'subactivities' => $activities->map(function($activity) { + 'subactivities' => $activities->map(function ($activity) { return ['subactivities' => $activity->subactivities->pluck('name', 'id'), 'id' => $activity->id]; })->pluck('subactivities', 'id'), 'billKinds' => BillKind::pluck('name', 'id'), diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index beb08a34..8f7bd002 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -5,7 +5,6 @@ namespace App\Member; 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; @@ -30,14 +29,16 @@ 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'), - 'subscription_id' => Rule::requiredIf(function() { - if ($this->method() != 'POST') { + 'first_activity_id' => Rule::requiredIf(fn () => 'POST' == $this->method()), + 'first_subactivity_id' => Rule::requiredIf(fn () => 'POST' == $this->method()), + 'subscription_id' => Rule::requiredIf(function () { + if ('POST' != $this->method()) { return false; } - if (!$this->input('first_activity_id')) { return true; } + if (!$this->input('first_activity_id')) { + return true; + } return Str::contains(Activity::findOrFail($this->input('first_activity_id'))->name, '€'); }), @@ -58,10 +59,11 @@ class MemberRequest extends FormRequest ]; } - public function persistCreate(): void { + public function persistCreate(): void + { $this->merge(['group_id' => Group::where('nami_id', Auth::user()->getNamiGroupId())->firstOrFail()->id]); $member = Member::create($this->input()); - if($this->input('has_nami')) { + if ($this->input('has_nami')) { CreateJob::dispatch($member, auth()->user()); } } @@ -70,13 +72,13 @@ class MemberRequest extends FormRequest { $member->update($this->input()); - if($this->input('has_nami') && $member->nami_id === null) { + if ($this->input('has_nami') && null === $member->nami_id) { CreateJob::dispatch($member, auth()->user()); } - if($this->input('has_nami') && $member->nami_id !== null) { + if ($this->input('has_nami') && null !== $member->nami_id) { UpdateJob::dispatch($member, auth()->user()); } - if(!$this->input('has_nami') && $member->nami_id !== null) { + if (!$this->input('has_nami') && null !== $member->nami_id) { DeleteJob::dispatch($member, auth()->user()); } } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index dc9fa2ae..21587a38 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -15,7 +15,8 @@ class MemberResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) @@ -50,7 +51,7 @@ class MemberResource extends JsonResource 'letter_address' => $this->letter_address, 'bill_kind_id' => $this->bill_kind_id, 'bill_kind_name' => optional($this->billKind)->name, - 'has_nami' => $this->nami_id !== null, + 'has_nami' => null !== $this->nami_id, 'is_confirmed' => $this->is_confirmed, 'children_phone' => $this->children_phone, 'payments' => PaymentResource::collection($this->whenLoaded('payments')), diff --git a/app/Member/Membership.php b/app/Member/Membership.php index c7af2608..ef7ad9ef 100644 --- a/app/Member/Membership.php +++ b/app/Member/Membership.php @@ -23,5 +23,4 @@ class Membership extends Model { return $this->belongsTo(Subactivity::class); } - } diff --git a/app/Member/UpdateJob.php b/app/Member/UpdateJob.php index 3b6ece88..58fc310f 100644 --- a/app/Member/UpdateJob.php +++ b/app/Member/UpdateJob.php @@ -4,17 +4,18 @@ namespace App\Member; use App\Confession; use App\Setting\NamiSettings; -use App\User; 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; class UpdateJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public int $memberId; public Member $member; @@ -65,7 +66,7 @@ class UpdateJob implements ShouldQueue 'group_id' => $this->member->group->nami_id, 'version' => $this->member->version, ]); - Member::withoutEvents(function() use ($response) { + Member::withoutEvents(function () use ($response) { $this->member->update(['version' => $response['version']]); }); } diff --git a/app/Membership/MembershipController.php b/app/Membership/MembershipController.php index 214774d6..6f7642c3 100644 --- a/app/Membership/MembershipController.php +++ b/app/Membership/MembershipController.php @@ -8,11 +8,9 @@ use App\Member\Membership; use App\Membership\Requests\StoreRequest; use App\Setting\NamiSettings; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; class MembershipController extends Controller { - public function store(Member $member, StoreRequest $request, NamiSettings $settings): RedirectResponse { $request->persist($member, $settings); @@ -30,5 +28,4 @@ class MembershipController extends Controller return redirect()->back(); } - } diff --git a/app/Membership/MembershipResource.php b/app/Membership/MembershipResource.php index 7c4fa205..3f164247 100644 --- a/app/Membership/MembershipResource.php +++ b/app/Membership/MembershipResource.php @@ -12,7 +12,8 @@ class MembershipResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Membership/Requests/StoreRequest.php b/app/Membership/Requests/StoreRequest.php index 2fca27d1..5d648a7b 100644 --- a/app/Membership/Requests/StoreRequest.php +++ b/app/Membership/Requests/StoreRequest.php @@ -11,7 +11,6 @@ use Zoomyboy\LaravelNami\Data\Membership; class StoreRequest extends FormRequest { - /** * Determine if the user is authorized to make this request. * @@ -30,7 +29,6 @@ class StoreRequest extends FormRequest public function rules() { return [ - // ]; } @@ -51,5 +49,4 @@ class StoreRequest extends FormRequest $member->syncVersion(); } - } diff --git a/app/Nami/HasNamiField.php b/app/Nami/HasNamiField.php index c5ba855d..5400a8e6 100644 --- a/app/Nami/HasNamiField.php +++ b/app/Nami/HasNamiField.php @@ -6,7 +6,6 @@ use Exception; trait HasNamiField { - public static function nami(int $id): self { $model = static::firstWhere('nami_id', $id); @@ -17,5 +16,4 @@ trait HasNamiField return $model; } - } diff --git a/app/Nationality.php b/app/Nationality.php index d4b46d85..2e00dde2 100644 --- a/app/Nationality.php +++ b/app/Nationality.php @@ -11,5 +11,5 @@ class Nationality extends Model use HasFactory; use HasNamiField; - public $fillable = ['name','nami_id']; + public $fillable = ['name', 'nami_id']; } diff --git a/app/Payment/ActionFactory.php b/app/Payment/ActionFactory.php index 31c793dd..a9b2c4f2 100644 --- a/app/Payment/ActionFactory.php +++ b/app/Payment/ActionFactory.php @@ -9,10 +9,9 @@ use Illuminate\Support\Collection; class ActionFactory { - public function forMember(Member $member): Collection { - return app(PdfRepositoryFactory::class)->getTypes()->map(function(PdfRepository $repo) use ($member): array { + return app(PdfRepositoryFactory::class)->getTypes()->map(function (PdfRepository $repo) use ($member): array { return [ 'href' => route('member.singlepdf', ['member' => $member, 'type' => get_class($repo)]), 'label' => $repo->linkLabel(), @@ -23,7 +22,7 @@ class ActionFactory public function allLinks(): Collection { - return app(PdfRepositoryFactory::class)->getTypes()->map(function(PdfRepository $repo) { + return app(PdfRepositoryFactory::class)->getTypes()->map(function (PdfRepository $repo) { return [ 'link' => [ 'href' => route('sendpayment.pdf', ['type' => get_class($repo)]), @@ -33,5 +32,4 @@ class ActionFactory ]; }); } - } diff --git a/app/Payment/AllpaymentController.php b/app/Payment/AllpaymentController.php index 15c14cff..7dc3c92d 100644 --- a/app/Payment/AllpaymentController.php +++ b/app/Payment/AllpaymentController.php @@ -4,7 +4,6 @@ namespace App\Payment; use App\Http\Controllers\Controller; use App\Member\Member; -use App\Payment\Status; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Inertia\Response; @@ -22,7 +21,7 @@ class AllpaymentController extends Controller public function store(Request $request): RedirectResponse { $request->validate([ - 'year' => 'required|numeric' + 'year' => 'required|numeric', ]); foreach (Member::payable()->whereNoPayment($request->year)->get() as $member) { diff --git a/app/Payment/Payment.php b/app/Payment/Payment.php index 05130541..2ef22c2c 100644 --- a/app/Payment/Payment.php +++ b/app/Payment/Payment.php @@ -3,8 +3,6 @@ namespace App\Payment; use App\Member\Member; -use App\Payment\Status; -use App\Payment\Subscription; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -33,21 +31,21 @@ class Payment extends Model public function scopeWhereNeedsPayment(Builder $q): Builder { - return $q->whereHas('status', function($q) { + return $q->whereHas('status', function ($q) { return $q->needsPayment(); }); } public function scopeWhereNeedsBill(Builder $q): Builder { - return $q->whereHas('status', function($q) { + return $q->whereHas('status', function ($q) { return $q->where('is_bill', true); }); } public function scopeWhereNeedsRemember(Builder $q): Builder { - return $q->whereHas('status', function($q) { + return $q->whereHas('status', function ($q) { return $q->where('is_remember', true); })->where(fn ($query) => $query->whereNull('last_remembered_at')->orWhere('last_remembered_at', '<=', now()->subMonths(3))); } diff --git a/app/Payment/PaymentController.php b/app/Payment/PaymentController.php index 4c6e42c1..ded1ab5d 100644 --- a/app/Payment/PaymentController.php +++ b/app/Payment/PaymentController.php @@ -5,7 +5,6 @@ namespace App\Payment; use App\Http\Controllers\Controller; use App\Http\Views\MemberView; use App\Member\Member; -use App\Member\MemberResource; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Inertia\Response; diff --git a/app/Payment/PaymentMail.php b/app/Payment/PaymentMail.php index e8c24664..098dd87b 100644 --- a/app/Payment/PaymentMail.php +++ b/app/Payment/PaymentMail.php @@ -4,15 +4,15 @@ namespace App\Payment; use App\Pdf\PdfRepository; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Str; class PaymentMail extends Mailable { - use Queueable, SerializesModels; - + use Queueable; + use SerializesModels; + public PdfRepository $repo; public string $filename; @@ -35,6 +35,7 @@ class PaymentMail extends Mailable public function build() { $template = Str::snake(class_basename($this->repo)); + return $this->markdown('mail.payment.'.$template) ->attach($this->filename) ->replyTo('kasse@stamm-silva.de') diff --git a/app/Payment/PaymentResource.php b/app/Payment/PaymentResource.php index 6a9ea563..3cc05deb 100644 --- a/app/Payment/PaymentResource.php +++ b/app/Payment/PaymentResource.php @@ -12,7 +12,8 @@ class PaymentResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) @@ -27,5 +28,4 @@ class PaymentResource extends JsonResource 'is_accepted' => $this->status->isAccepted(), ]; } - } diff --git a/app/Payment/PaymentSendCommand.php b/app/Payment/PaymentSendCommand.php index 8c4fa5ae..3fbc0e27 100644 --- a/app/Payment/PaymentSendCommand.php +++ b/app/Payment/PaymentSendCommand.php @@ -77,5 +77,4 @@ class PaymentSendCommand extends Command app(PdfRepositoryFactory::class)->afterSingle($repo); } } - } diff --git a/app/Payment/SendpaymentController.php b/app/Payment/SendpaymentController.php index 4deb306c..1ef21ffd 100644 --- a/app/Payment/SendpaymentController.php +++ b/app/Payment/SendpaymentController.php @@ -4,7 +4,6 @@ namespace App\Payment; use App\Http\Controllers\Controller; use App\Pdf\PdfGenerator; -use App\Pdf\PdfRepository; use App\Pdf\PdfRepositoryFactory; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Request; @@ -14,7 +13,6 @@ use Inertia\Response as InertiaResponse; class SendpaymentController extends Controller { - public function create(): InertiaResponse { session()->put('menu', 'member'); @@ -35,9 +33,8 @@ class SendpaymentController extends Controller $pdfFile = app(PdfGenerator::class)->setRepository($repo)->render(); app(PdfRepositoryFactory::class)->afterAll($request->type, 'Post'); - return $repo === null + return null === $repo ? response()->noContent() : $pdfFile; } - } diff --git a/app/Payment/Status.php b/app/Payment/Status.php index e5e77ae7..5f0ce05e 100644 --- a/app/Payment/Status.php +++ b/app/Payment/Status.php @@ -17,7 +17,6 @@ class Status extends Model 'is_remember' => 'boolean', ]; - public static function default(): int { return static::where('is_bill', true)->where('is_remember', true)->first()->id; @@ -25,13 +24,13 @@ class Status extends Model public function isAccepted(): bool { - return $this->is_bill === false && $this->is_remember === false; + return false === $this->is_bill && false === $this->is_remember; } // ---------------------------------- Scopes ----------------------------------- public function scopeNeedsPayment(Builder $query): Builder { - return $query->where(function(Builder $query): Builder { + return $query->where(function (Builder $query): Builder { return $query->where('is_bill', true)->orWhere('is_remember', true); }); } diff --git a/app/Payment/Subscription.php b/app/Payment/Subscription.php index f573aaab..f0365afa 100644 --- a/app/Payment/Subscription.php +++ b/app/Payment/Subscription.php @@ -13,7 +13,8 @@ class Subscription extends Model public $fillable = ['name', 'amount', 'fee_id']; - public function fee(): BelongsTo { + public function fee(): BelongsTo + { return $this->belongsTo(Fee::class); } } diff --git a/app/Payment/SubscriptionController.php b/app/Payment/SubscriptionController.php index 425ed53f..5db251c4 100644 --- a/app/Payment/SubscriptionController.php +++ b/app/Payment/SubscriptionController.php @@ -17,7 +17,7 @@ class SubscriptionController extends Controller return \Inertia::render('subscription/SubscriptionIndex', [ 'data' => SubscriptionResource::collection(Subscription::get()), - 'toolbar' => [ ['href' => route('subscription.create'), 'label' => 'Beitrag anlegen', 'color' => 'primary', 'icon' => 'plus'] ], + 'toolbar' => [['href' => route('subscription.create'), 'label' => 'Beitrag anlegen', 'color' => 'primary', 'icon' => 'plus']], ]); } @@ -29,7 +29,7 @@ class SubscriptionController extends Controller return \Inertia::render('subscription/SubscriptionForm', [ 'fees' => Fee::pluck('name', 'id'), 'mode' => 'create', - 'data' => (object) [] + 'data' => (object) [], ]); } diff --git a/app/Payment/SubscriptionResource.php b/app/Payment/SubscriptionResource.php index adbb9780..76c8937f 100644 --- a/app/Payment/SubscriptionResource.php +++ b/app/Payment/SubscriptionResource.php @@ -12,7 +12,8 @@ class SubscriptionResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request + * * @return array */ public function toArray($request) diff --git a/app/Pdf/BillType.php b/app/Pdf/BillType.php index a026f060..57d43ba9 100644 --- a/app/Pdf/BillType.php +++ b/app/Pdf/BillType.php @@ -8,7 +8,6 @@ use Illuminate\Support\Collection; class BillType extends Repository implements PdfRepository { - public string $filename; public function getPayments(Member $member): Collection @@ -97,7 +96,7 @@ class BillType extends Repository implements PdfRepository } /** - * Get Descriptions for sendpayment page + * Get Descriptions for sendpayment page. * * @return array */ @@ -118,5 +117,4 @@ class BillType extends Repository implements PdfRepository { return 'Jahresrechnung'; } - } diff --git a/app/Pdf/MemberPdfController.php b/app/Pdf/MemberPdfController.php index b206a479..7dae0cd9 100644 --- a/app/Pdf/MemberPdfController.php +++ b/app/Pdf/MemberPdfController.php @@ -10,7 +10,6 @@ use Illuminate\Http\Response; class MemberPdfController extends Controller { - /** * @return Response|Responsable */ @@ -18,9 +17,8 @@ class MemberPdfController extends Controller { $repo = app(PdfRepositoryFactory::class)->fromSingleRequest($request->type, $member); - return $repo === null + return null === $repo ? response()->noContent() : app(PdfGenerator::class)->setRepository($repo)->render(); } - } diff --git a/app/Pdf/PdfGenerator.php b/app/Pdf/PdfGenerator.php index ae92af9a..9c75bd11 100644 --- a/app/Pdf/PdfGenerator.php +++ b/app/Pdf/PdfGenerator.php @@ -8,7 +8,6 @@ use Storage; class PdfGenerator implements Responsable { - private ?string $filename = null; private PdfRepository $repo; private string $dir; @@ -62,5 +61,4 @@ class PdfGenerator implements Responsable $templatePath = resource_path("views/tex/templates/{$this->repo->getTemplate()}"); exec('cp '.$templatePath.'/* '.$destination); } - } diff --git a/app/Pdf/PdfRepository.php b/app/Pdf/PdfRepository.php index 6f0a9044..58edcd7f 100644 --- a/app/Pdf/PdfRepository.php +++ b/app/Pdf/PdfRepository.php @@ -10,7 +10,6 @@ use Illuminate\Support\Collection; interface PdfRepository { - public function getSubject(): string; public function setFilename(string $filename): self; @@ -52,5 +51,4 @@ interface PdfRepository public function getMailSubject(): string; public function allPayments(): Generator; - } diff --git a/app/Pdf/PdfRepositoryFactory.php b/app/Pdf/PdfRepositoryFactory.php index ff4cd4b4..98cb5047 100644 --- a/app/Pdf/PdfRepositoryFactory.php +++ b/app/Pdf/PdfRepositoryFactory.php @@ -9,7 +9,6 @@ use Illuminate\Support\Str; class PdfRepositoryFactory { - /** * @var array> */ @@ -23,7 +22,7 @@ class PdfRepositoryFactory */ public function getTypes(): Collection { - return collect(array_map(fn ($classString) => new $classString, $this->types)); + return collect(array_map(fn ($classString) => new $classString(), $this->types)); } public function fromSingleRequest(string $type, Member $member): ?PdfRepository @@ -108,5 +107,4 @@ class PdfRepositoryFactory ), ); } - } diff --git a/app/Pdf/RememberType.php b/app/Pdf/RememberType.php index 2dd5c38d..20d6ea08 100644 --- a/app/Pdf/RememberType.php +++ b/app/Pdf/RememberType.php @@ -8,7 +8,6 @@ use Illuminate\Support\Collection; class RememberType extends Repository implements PdfRepository { - public string $filename; public function getPayments(Member $member): Collection @@ -97,11 +96,11 @@ class RememberType extends Repository implements PdfRepository } /** - * Get Descriptions for sendpayment page + * Get Descriptions for sendpayment page. * * @return array */ - public function getDescription(): array + public function getDescription(): array { return [ 'Diese Funktion erstellt Erinnerungs-PDFs mit allen versendeten aber noch nich bezahlten Rechnungen bei den Mitgliedern die Post als Versandweg haben.', @@ -118,5 +117,4 @@ class RememberType extends Repository implements PdfRepository { return 'Zahlungserinnerung'; } - } diff --git a/app/Pdf/Repository.php b/app/Pdf/Repository.php index 663b5452..4b603783 100644 --- a/app/Pdf/Repository.php +++ b/app/Pdf/Repository.php @@ -9,7 +9,6 @@ use Illuminate\Support\Collection; abstract class Repository { - abstract public function getPayments(Member $member): Collection; public Collection $pages; @@ -31,7 +30,7 @@ abstract class Repository public function createable(Member $member): bool { - return $this->getPayments($member)->count() !== 0; + return 0 !== $this->getPayments($member)->count(); } public function allPayments(): Generator @@ -44,5 +43,4 @@ abstract class Repository } } } - } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1beefe13..ef1f90f1 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,10 +2,8 @@ namespace App\Providers; -use App\Setting\GeneralSettings; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Resources\Json\JsonResource; -use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; use Laravel\Telescope\Telescope; @@ -23,7 +21,7 @@ class AppServiceProvider extends ServiceProvider \Inertia::share('search', request()->query('search', '')); - RedirectResponse::macro('success', function($flash) { + RedirectResponse::macro('success', function ($flash) { session()->flash('flash', ['success' => $flash]); return $this; @@ -37,6 +35,5 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - // } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 30490683..7971bf7c 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -3,7 +3,6 @@ namespace App\Providers; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; -use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { @@ -24,7 +23,5 @@ class AuthServiceProvider extends ServiceProvider public function boot() { $this->registerPolicies(); - - // } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 723a290d..eac358ce 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -28,7 +28,5 @@ class EventServiceProvider extends ServiceProvider public function boot() { parent::boot(); - - // } } diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php index 08881175..8b5afd7b 100644 --- a/app/Providers/HorizonServiceProvider.php +++ b/app/Providers/HorizonServiceProvider.php @@ -35,7 +35,6 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider { Gate::define('viewHorizon', function ($user) { return in_array($user->email, [ - // ]); }); } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 51336ecd..ac05f5d6 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -30,8 +30,6 @@ class RouteServiceProvider extends ServiceProvider */ public function boot() { - // - parent::boot(); } diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index f6e34845..834edd38 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -63,7 +63,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider protected function gate() { Gate::define('viewTelescope', function ($user) { - return $user->mglnr == 90166; + return 90166 == $user->mglnr; }); } } diff --git a/app/Region.php b/app/Region.php index 82b30bcb..c302e9d5 100644 --- a/app/Region.php +++ b/app/Region.php @@ -11,6 +11,6 @@ class Region extends Model public $fillable = ['name', 'nami_id', 'is_null']; public $casts = [ - 'is_null' => 'boolean' + 'is_null' => 'boolean', ]; } diff --git a/app/Setting/Controllers/SettingController.php b/app/Setting/Controllers/SettingController.php index 928d07c2..feac1823 100644 --- a/app/Setting/Controllers/SettingController.php +++ b/app/Setting/Controllers/SettingController.php @@ -4,13 +4,11 @@ namespace App\Setting\Controllers; use App\Http\Controllers\Controller; use App\Setting\GeneralSettings; -use Illuminate\Http\Request; use Inertia\Inertia; use Inertia\Response; class SettingController extends Controller { - /** * @wip */ @@ -18,12 +16,11 @@ class SettingController extends Controller { return Inertia::render('setting/Index', [ 'options' => [ - 'modules' => $generalSettings->moduleOptions() + 'modules' => $generalSettings->moduleOptions(), ], 'general' => [ - 'modules' => $generalSettings->modules - ] + 'modules' => $generalSettings->modules, + ], ]); } - } diff --git a/app/Setting/GeneralSettings.php b/app/Setting/GeneralSettings.php index 0504989d..9bb4950d 100644 --- a/app/Setting/GeneralSettings.php +++ b/app/Setting/GeneralSettings.php @@ -6,7 +6,6 @@ use Spatie\LaravelSettings\Settings; class GeneralSettings extends Settings { - /** @var array */ public array $modules; @@ -34,5 +33,4 @@ class GeneralSettings extends Settings { return in_array($module, $this->modules); } - } diff --git a/app/Setting/NamiSettings.php b/app/Setting/NamiSettings.php index 394271bd..d91d6e0c 100644 --- a/app/Setting/NamiSettings.php +++ b/app/Setting/NamiSettings.php @@ -8,7 +8,6 @@ use Zoomyboy\LaravelNami\Nami; class NamiSettings extends Settings { - public int $mglnr; public string $password; @@ -22,5 +21,4 @@ class NamiSettings extends Settings { return Nami::login($this->mglnr, $this->password); } - } diff --git a/app/Subactivity.php b/app/Subactivity.php index 171af4b1..12a89f90 100644 --- a/app/Subactivity.php +++ b/app/Subactivity.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Subactivity extends Model { - use HasFactory; use HasNamiField; use Sluggable; @@ -36,5 +35,4 @@ class Subactivity extends Model { return $this->belongsToMany(Activity::class); } - } diff --git a/app/Tex/TexCompiler.php b/app/Tex/TexCompiler.php index 9acc455b..8edb7f2c 100644 --- a/app/Tex/TexCompiler.php +++ b/app/Tex/TexCompiler.php @@ -6,7 +6,5 @@ use Illuminate\View\Compilers\BladeCompiler; class TexCompiler extends BladeCompiler { - protected $contentTags = ['<<<', '>>>']; - } diff --git a/app/Tex/TexServiceProvider.php b/app/Tex/TexServiceProvider.php index cea362cf..a4677e7e 100644 --- a/app/Tex/TexServiceProvider.php +++ b/app/Tex/TexServiceProvider.php @@ -3,8 +3,6 @@ namespace App\Tex; use Illuminate\Support\ServiceProvider; -use Illuminate\View\Compilers\BladeCompiler; -use Illuminate\View\DynamicComponent; use Illuminate\View\Engines\CompilerEngine; class TexServiceProvider extends ServiceProvider @@ -16,7 +14,7 @@ class TexServiceProvider extends ServiceProvider */ public function register() { - view()->addExtension('tex', 'tex', function() { + view()->addExtension('tex', 'tex', function () { $compiler = new TexCompiler(app('files'), config('view.compiled')); return new CompilerEngine($compiler, app('files')); @@ -30,6 +28,5 @@ class TexServiceProvider extends ServiceProvider */ public function boot() { - // } } diff --git a/app/User.php b/app/User.php index 8c4516c4..33cf436f 100644 --- a/app/User.php +++ b/app/User.php @@ -2,15 +2,10 @@ namespace App; -use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Auth\User as Authenticatable; -use Illuminate\Notifications\Notifiable; class User extends Authenticatable { - use HasFactory; - } diff --git a/database/factories/ActivityFactory.php b/database/factories/ActivityFactory.php index 410da3e6..2202a642 100644 --- a/database/factories/ActivityFactory.php +++ b/database/factories/ActivityFactory.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; */ class ActivityFactory extends Factory { - protected $model = Activity::class; /** @@ -30,5 +29,4 @@ class ActivityFactory extends Factory { return $this->state(['nami_id' => $namiId]); } - } diff --git a/database/factories/ConfessionFactory.php b/database/factories/ConfessionFactory.php index 76d66cc9..ca64714a 100644 --- a/database/factories/ConfessionFactory.php +++ b/database/factories/ConfessionFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class ConfessionFactory extends Factory { - protected $model = Confession::class; /** diff --git a/database/factories/CountryFactory.php b/database/factories/CountryFactory.php index a1b4042c..69ce0675 100644 --- a/database/factories/CountryFactory.php +++ b/database/factories/CountryFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class CountryFactory extends Factory { - protected $model = Country::class; /** diff --git a/database/factories/Course/Models/CourseFactory.php b/database/factories/Course/Models/CourseFactory.php index 77b0ee61..af2b9aa5 100644 --- a/database/factories/Course/Models/CourseFactory.php +++ b/database/factories/Course/Models/CourseFactory.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; */ class CourseFactory extends Factory { - public $model = Course::class; /** diff --git a/database/factories/Course/Models/CourseMemberFactory.php b/database/factories/Course/Models/CourseMemberFactory.php index 5e71013c..abac0627 100644 --- a/database/factories/Course/Models/CourseMemberFactory.php +++ b/database/factories/Course/Models/CourseMemberFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class CourseMemberFactory extends Factory { - public $model = CourseMember::class; /** diff --git a/database/factories/FeeFactory.php b/database/factories/FeeFactory.php index af55bece..36d4bdaa 100644 --- a/database/factories/FeeFactory.php +++ b/database/factories/FeeFactory.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; */ class FeeFactory extends Factory { - protected $model = Fee::class; /** diff --git a/database/factories/GroupFactory.php b/database/factories/GroupFactory.php index c32f25d2..62d42787 100644 --- a/database/factories/GroupFactory.php +++ b/database/factories/GroupFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class GroupFactory extends Factory { - protected $model = Group::class; /** diff --git a/database/factories/NationalityFactory.php b/database/factories/NationalityFactory.php index 082a5a2f..0342fae4 100644 --- a/database/factories/NationalityFactory.php +++ b/database/factories/NationalityFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class NationalityFactory extends Factory { - protected $model = Nationality::class; /** diff --git a/database/factories/Payment/PaymentFactory.php b/database/factories/Payment/PaymentFactory.php index f9f63a0b..c930d114 100644 --- a/database/factories/Payment/PaymentFactory.php +++ b/database/factories/Payment/PaymentFactory.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class PaymentFactory extends Factory { - protected $model = Payment::class; public function definition(): array @@ -44,5 +43,4 @@ class PaymentFactory extends Factory Subscription::factory()->state(['name' => $name, 'amount' => $amount])->for(Fee::first()), ); } - } diff --git a/database/factories/Payment/StatusFactory.php b/database/factories/Payment/StatusFactory.php index ca8b6f95..a521069e 100644 --- a/database/factories/Payment/StatusFactory.php +++ b/database/factories/Payment/StatusFactory.php @@ -7,7 +7,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class StatusFactory extends Factory { - public $model = Status::class; /** diff --git a/database/factories/Payment/SubscriptionFactory.php b/database/factories/Payment/SubscriptionFactory.php index 2ed22003..24c26bee 100644 --- a/database/factories/Payment/SubscriptionFactory.php +++ b/database/factories/Payment/SubscriptionFactory.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; class SubscriptionFactory extends Factory { - protected $model = Subscription::class; public function definition(): array @@ -19,5 +18,4 @@ class SubscriptionFactory extends Factory 'fee_id' => Fee::factory()->createOne()->id, ]; } - } diff --git a/database/factories/SubactivityFactory.php b/database/factories/SubactivityFactory.php index f94d7ba0..91ae064e 100644 --- a/database/factories/SubactivityFactory.php +++ b/database/factories/SubactivityFactory.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Factories\Factory; */ class SubactivityFactory extends Factory { - protected $model = Subactivity::class; /** @@ -30,5 +29,4 @@ class SubactivityFactory extends Factory { return $this->state(['nami_id' => $namiId]); } - } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 491c2f9d..58673ba5 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -11,7 +11,6 @@ use Illuminate\Support\Facades\Hash; */ class UserFactory extends Factory { - protected $model = User::class; /** diff --git a/database/migrations/2017_12_25_231219_create_ways_table.php b/database/migrations/2017_12_25_231219_create_ways_table.php index 85748294..5f4a4625 100644 --- a/database/migrations/2017_12_25_231219_create_ways_table.php +++ b/database/migrations/2017_12_25_231219_create_ways_table.php @@ -1,8 +1,8 @@ id(); $table->string('name'); $table->boolean('is_bill'); diff --git a/database/migrations/2021_11_18_001427_create_courses_table.php b/database/migrations/2021_11_18_001427_create_courses_table.php index 549d78f7..3a9b7af1 100644 --- a/database/migrations/2021_11_18_001427_create_courses_table.php +++ b/database/migrations/2021_11_18_001427_create_courses_table.php @@ -18,7 +18,7 @@ class CreateCoursesTable extends Migration $table->unsignedInteger('nami_id'); $table->string('name'); }); - Schema::create('course_members', function($table) { + Schema::create('course_members', function ($table) { $table->id(); $table->foreignId('member_id')->constrained(); $table->foreignId('course_id')->constrained(); diff --git a/database/migrations/2022_01_18_205354_create_memberships_table.php b/database/migrations/2022_01_18_205354_create_memberships_table.php index 352a3883..f9d3f899 100644 --- a/database/migrations/2022_01_18_205354_create_memberships_table.php +++ b/database/migrations/2022_01_18_205354_create_memberships_table.php @@ -23,7 +23,6 @@ class CreateMembershipsTable extends Migration $table->foreignId('activity_id')->constrained(); $table->foreignId('subactivity_id')->nullable()->constrained(); $table->unique(['activity_id', 'subactivity_id', 'group_id', 'member_id', 'nami_id'], 'memberships_unique'); - }); } diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 953aeadc..34b161be 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -15,7 +15,7 @@ class UserSeeder extends Seeder User::factory()->create([ 'email' => 'admin@example.com', 'email_verified_at' => now(), - 'password' => Hash::make('admin') + 'password' => Hash::make('admin'), ]); } } diff --git a/database/settings/2021_11_18_230152_create_general_settings.php b/database/settings/2021_11_18_230152_create_general_settings.php index 1fd9f7b1..92b86096 100644 --- a/database/settings/2021_11_18_230152_create_general_settings.php +++ b/database/settings/2021_11_18_230152_create_general_settings.php @@ -4,9 +4,7 @@ use Spatie\LaravelSettings\Migrations\SettingsMigration; class CreateGeneralSettings extends SettingsMigration { - /** - * @param string $mode * @return array|bool> */ public function defaults(string $mode): array @@ -19,7 +17,7 @@ class CreateGeneralSettings extends SettingsMigration 'stamm' => [ 'modules' => ['bill', 'courses'], 'single_view' => true, - ] + ], ]; return $defaults[$mode]; diff --git a/database/settings/2022_02_19_230152_create_nami_settings.php b/database/settings/2022_02_19_230152_create_nami_settings.php index 46e5bfe0..f63393cf 100644 --- a/database/settings/2022_02_19_230152_create_nami_settings.php +++ b/database/settings/2022_02_19_230152_create_nami_settings.php @@ -4,10 +4,9 @@ use Spatie\LaravelSettings\Migrations\SettingsMigration; class CreateNamiSettings extends SettingsMigration { - public function up(): void { - $this->migrator->add('nami.mglnr', (int)env('NAMI_MGLNR')); + $this->migrator->add('nami.mglnr', (int) env('NAMI_MGLNR')); $this->migrator->add('nami.password', env('NAMI_PASSWORD')); } } diff --git a/tests/Feature/Course/DeleteTest.php b/tests/Feature/Course/DeleteTest.php index 1c61d346..d637269b 100644 --- a/tests/Feature/Course/DeleteTest.php +++ b/tests/Feature/Course/DeleteTest.php @@ -6,14 +6,11 @@ use App\Course\Models\Course; use App\Course\Models\CourseMember; use App\Member\Member; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; -use Zoomyboy\LaravelNami\Backend\FakeBackend; use Zoomyboy\LaravelNami\Fakes\CourseFake; class DeleteTest extends TestCase { - use DatabaseTransactions; public function testItDeletesACourse(): void @@ -39,5 +36,4 @@ class DeleteTest extends TestCase $this->assertDatabaseCount('course_members', 1); $response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']); } - } diff --git a/tests/Feature/Course/StoreTest.php b/tests/Feature/Course/StoreTest.php index 8e1b2c81..4171aa1f 100644 --- a/tests/Feature/Course/StoreTest.php +++ b/tests/Feature/Course/StoreTest.php @@ -5,14 +5,11 @@ namespace Tests\Feature\Course; use App\Course\Models\Course; use App\Member\Member; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; -use Zoomyboy\LaravelNami\Backend\FakeBackend; use Zoomyboy\LaravelNami\Fakes\CourseFake; class StoreTest extends TestCase { - use DatabaseTransactions; /** @@ -132,9 +129,8 @@ class StoreTest extends TestCase 'event_name' => '::event::', 'organizer' => '::org::', ]); - + $response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']); $this->assertDatabaseCount('course_members', 0); } - } diff --git a/tests/Feature/Course/UpdateTest.php b/tests/Feature/Course/UpdateTest.php index 5d9a9377..08e9f386 100644 --- a/tests/Feature/Course/UpdateTest.php +++ b/tests/Feature/Course/UpdateTest.php @@ -6,14 +6,11 @@ use App\Course\Models\Course; use App\Course\Models\CourseMember; use App\Member\Member; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; -use Zoomyboy\LaravelNami\Backend\FakeBackend; use Zoomyboy\LaravelNami\Fakes\CourseFake; class UpdateTest extends TestCase { - use DatabaseTransactions; /** @@ -133,5 +130,4 @@ class UpdateTest extends TestCase $response->assertSessionHasErrors(['id' => 'Unbekannter Fehler']); } - } diff --git a/tests/Feature/Initialize/InitializeTest.php b/tests/Feature/Initialize/InitializeTest.php index 89535d01..1ebc1720 100644 --- a/tests/Feature/Initialize/InitializeTest.php +++ b/tests/Feature/Initialize/InitializeTest.php @@ -13,18 +13,15 @@ use App\Nationality; use App\Setting\GeneralSettings; use App\Subactivity; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Http; use Tests\TestCase; use Zoomyboy\LaravelNami\Backend\FakeBackend; use Zoomyboy\LaravelNami\Fakes\GroupFake; -use Zoomyboy\LaravelNami\Fakes\MemberFake; use Zoomyboy\LaravelNami\Fakes\SearchFake; class InitializeTest extends TestCase { - use DatabaseTransactions; public function initializeProvider(callable $callback = null): void @@ -65,7 +62,7 @@ class InitializeTest extends TestCase } $backend->fakeSubactivities([ - 305 => [['name' => 'wö', 'id' => 306]] + 305 => [['name' => 'wö', 'id' => 306]], ]); } @@ -78,35 +75,35 @@ class InitializeTest extends TestCase $this->assertDatabaseHas('regions', [ 'name' => 'nrw', - 'nami_id' => 304 + 'nami_id' => 304, ]); $this->assertDatabaseHas('genders', [ 'name' => 'Male', - 'nami_id' => 303 + 'nami_id' => 303, ]); $this->assertDatabaseHas('nationalities', [ 'name' => 'deutsch', - 'nami_id' => 291 + 'nami_id' => 291, ]); $this->assertDatabaseHas('fees', [ 'name' => 'Family', - 'nami_id' => 300 + 'nami_id' => 300, ]); $this->assertDatabaseHas('confessions', [ 'name' => 'Konf', - 'nami_id' => 301 + 'nami_id' => 301, ]); $this->assertDatabaseHas('countries', [ 'name' => 'Germany', - 'nami_id' => 302 + 'nami_id' => 302, ]); $this->assertDatabaseHas('activities', [ 'name' => '€ Leiter', - 'nami_id' => 305 + 'nami_id' => 305, ]); $this->assertDatabaseHas('courses', [ 'name' => '1a', - 'nami_id' => 506 + 'nami_id' => 506, ]); $this->assertDatabaseHas('groups', ['nami_id' => 1000, 'name' => '::group::']); $this->assertDatabaseHas('members', [ @@ -135,16 +132,16 @@ class InitializeTest extends TestCase $this->assertDatabaseHas('regions', [ 'name' => 'nrw', - 'nami_id' => 304 + 'nami_id' => 304, ]); } public function testSyncCoursesOfMember(): void { $this->withoutExceptionHandling()->login()->loginNami(); - $this->initializeProvider(function($backend) { + $this->initializeProvider(function ($backend) { $backend->fakeMembers([ - $this->member(['courses' => [ ['bausteinId' => 506, 'id' => 788, 'veranstalter' => 'KJA', 'vstgName' => 'eventname', 'vstgTag' => '2021-11-12 00:00:00'] ]]) + $this->member(['courses' => [['bausteinId' => 506, 'id' => 788, 'veranstalter' => 'KJA', 'vstgName' => 'eventname', 'vstgTag' => '2021-11-12 00:00:00']]]), ]); }); $this->login(); @@ -170,10 +167,10 @@ class InitializeTest extends TestCase 'id' => 1077, 'taetigkeit' => '::newtaetigkeit:: (9001)', ], - function($db) { + function ($db) { $db->assertDatabaseCount('memberships', 0); }, - function($backend) { + function ($backend) { return $backend->fakeSingleMembership(116, 1077, [ 'aktivVon' => '2021-08-22 00:00:00', 'aktivBis' => '', @@ -185,7 +182,7 @@ class InitializeTest extends TestCase 'untergliederungId' => 306, ]) ->fakeActivities(9056, []); - } + }, ], 'normal' => [ [ @@ -196,7 +193,7 @@ class InitializeTest extends TestCase 'taetigkeit' => '€ leiter (305)', 'untergliederung' => 'wö', ], - function($db) { + function ($db) { $db->assertDatabaseHas('memberships', [ 'member_id' => Member::where('firstname', '::firstname::')->firstOrFail()->id, 'activity_id' => Activity::where('nami_id', 305)->firstOrFail()->id, @@ -213,7 +210,7 @@ class InitializeTest extends TestCase 'id' => 1077, 'untergliederung' => '::newuntertaetigkeit::', ], - function($db) { + function ($db) { $db->assertDatabaseHas('subactivities', ['name' => 'wö2', 'nami_id' => 3007]); $db->assertDatabaseHas('activity_subactivity', [ 'activity_id' => Activity::where('nami_id', 305)->firstOrFail()->id, @@ -226,7 +223,7 @@ class InitializeTest extends TestCase 'nami_id' => 1077, ]); }, - function($backend) { + function ($backend) { return $backend->fakeSingleMembership(116, 1077, [ 'aktivVon' => '2021-08-22 00:00:00', 'aktivBis' => '', @@ -243,9 +240,9 @@ class InitializeTest extends TestCase 305 => [ ['name' => 'wö', 'id' => 306], ['name' => 'wö2', 'id' => 3007], - ] + ], ]); - } + }, ], 'fetch_activity_from_group' => [ [ @@ -253,7 +250,7 @@ class InitializeTest extends TestCase 'id' => 1077, 'taetigkeit' => '::newtaetigkeit:: (9001)', ], - function($db) { + function ($db) { $db->assertDatabaseHas('activities', ['name' => '::newtaetigkeit::', 'nami_id' => 4000]); $db->assertDatabaseHas('groups', ['name' => '::newgroup::', 'nami_id' => 9056]); $db->assertDatabaseHas('activity_subactivity', [ @@ -266,7 +263,7 @@ class InitializeTest extends TestCase 'nami_id' => 1077, ]); }, - function($backend) { + function ($backend) { return $backend->fakeSingleMembership(116, 1077, [ 'aktivVon' => '2021-08-22 00:00:00', 'aktivBis' => '', @@ -279,18 +276,18 @@ class InitializeTest extends TestCase ]) ->fakeActivities(9056, [['name' => '::newtaetigkeit::', 'id' => 4000]]) ->fakeSubactivities([ - 4000 => [['name' => 'wö', 'id' => 306]] + 4000 => [['name' => 'wö', 'id' => 306]], ]); - } + }, ], 'new_group' => [ [ 'gruppierung' => '::new group:: 5555', ], - function($db) { + function ($db) { $db->assertDatabaseHas('groups', ['name' => '::new group::', 'nami_id' => 5555]); }, - function($backend) { + function ($backend) { return $backend->fakeSingleMembership(116, 1077, [ 'aktivVon' => '2021-08-22 00:00:00', 'aktivBis' => '', @@ -302,16 +299,15 @@ class InitializeTest extends TestCase ]) ->fakeActivities(5555, [['name' => 'mitglied', 'id' => 310]]) ->fakeSubactivities([ - 310 => [['name' => 'wö', 'id' => 306]] + 310 => [['name' => 'wö', 'id' => 306]], ]); - - } + }, ], 'no_subactivity' => [ [ 'untergliederung' => '', ], - function($db) { + function ($db) { $db->assertDatabaseHas('memberships', ['subactivity_id' => null]); }, ], @@ -319,7 +315,7 @@ class InitializeTest extends TestCase [ 'aktivVon' => '1014-04-01 00:00:00', ], - function($db) { + function ($db) { $db->assertDatabaseHas('memberships', [ 'from' => '1014-04-01 00:00:00', ]); @@ -329,7 +325,7 @@ class InitializeTest extends TestCase [ 'aktivBis' => '2021-08-25 00:00:00', ], - function($db) { + function ($db) { $db->assertDatabaseCount('memberships', 0); }, ], @@ -342,10 +338,10 @@ class InitializeTest extends TestCase public function testSyncMembershipsOfMember(array $membership, callable $dbcheck, ?callable $backendCallback = null): void { if (!$backendCallback) { - $backendCallback = function($backend) { return $backend; }; + $backendCallback = function ($backend) { return $backend; }; } $this->withoutExceptionHandling()->login()->loginNami(); - $this->initializeProvider(function($backend) use ($membership, $backendCallback) { + $this->initializeProvider(function ($backend) use ($membership, $backendCallback) { $backend->fakeMembers([ $this->member([ 'memberships' => [array_merge([ @@ -356,7 +352,7 @@ class InitializeTest extends TestCase 'taetigkeit' => 'leiter (305)', 'untergliederung' => 'wö', ], $membership)], - ]) + ]), ]); $backendCallback($backend); }); @@ -369,7 +365,7 @@ class InitializeTest extends TestCase public function testItDoesntGetMembersWithNoJoinedAtDate(): void { $this->withoutExceptionHandling()->login()->loginNami(); - $this->initializeProvider(function($backend) { + $this->initializeProvider(function ($backend) { $backend->fakeMembers([$this->member(['eintrittsdatum' => null])]); }); $this->login(); @@ -400,7 +396,7 @@ class InitializeTest extends TestCase public function testItInitializesPages(int $num): void { $this->withoutExceptionHandling()->login()->loginNami(); - $this->initializeProvider(function($backend) use ($num) { + $this->initializeProvider(function ($backend) use ($num) { $members = collect([]); foreach (range(1, $num) as $i) { @@ -419,7 +415,7 @@ class InitializeTest extends TestCase public function testRenderErrorInConsoleWhenUsingArtisan(): void { $this->withoutExceptionHandling()->login()->loginNami(); - $this->initializeProvider(function($backend) { + $this->initializeProvider(function ($backend) { app(SearchFake::class)->fetchFails($page = 1, $start = 0, 'search error'); }); $this->login(); @@ -433,6 +429,7 @@ class InitializeTest extends TestCase /** * @param array $overwrites + * * @return array */ private function member(array $overwrites): array @@ -456,5 +453,4 @@ class InitializeTest extends TestCase 'gruppierung' => '::group::', ], $overwrites); } - } diff --git a/tests/Feature/Member/IndexTest.php b/tests/Feature/Member/IndexTest.php index 934bf18c..67c74137 100644 --- a/tests/Feature/Member/IndexTest.php +++ b/tests/Feature/Member/IndexTest.php @@ -11,7 +11,6 @@ use Zoomyboy\LaravelNami\Backend\FakeBackend; class IndexTest extends TestCase { - use DatabaseTransactions; public function testItGetsMembers(): void @@ -44,5 +43,4 @@ class IndexTest extends TestCase $this->assertComponent('member/VIndex', $response); $this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname'); } - } diff --git a/tests/Feature/Member/UpdateTest.php b/tests/Feature/Member/UpdateTest.php index a529151b..69d1f9e6 100644 --- a/tests/Feature/Member/UpdateTest.php +++ b/tests/Feature/Member/UpdateTest.php @@ -4,8 +4,6 @@ namespace Tests\Feature\Member; use App\Confession; use App\Country; -use App\Course\Models\Course; -use App\Course\Models\CourseMember; use App\Fee; use App\Group; use App\Member\Member; @@ -13,13 +11,11 @@ use App\Nationality; use App\Payment\Subscription; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Http; -use Illuminate\Support\Str; use Tests\TestCase; use Zoomyboy\LaravelNami\Backend\FakeBackend; class UpdateTest extends TestCase { - use DatabaseTransactions; public function testItRedirectsToMemberOverview(): void @@ -45,8 +41,8 @@ class UpdateTest extends TestCase ->from("/member/{$member->id}") ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::'])); - Http::assertSent(fn ($request) => $request->method() === 'PUT' - && $request['vorname'] === '::firstname::' + Http::assertSent(fn ($request) => 'PUT' === $request->method() + && '::firstname::' === $request['vorname'] ); } @@ -60,10 +56,10 @@ class UpdateTest extends TestCase ->from("/member/{$member->id}") ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::'])); - Http::assertSent(fn ($request) => $request->method() === 'PUT' - && $request['kontoverbindung'] === '{"a":"b"}' - && $request['missingkey'] === 'missingvalue' - && $request['vorname'] === '::firstname::' + Http::assertSent(fn ($request) => 'PUT' === $request->method() + && '{"a":"b"}' === $request['kontoverbindung'] + && 'missingvalue' === $request['missingkey'] + && '::firstname::' === $request['vorname'] ); } @@ -88,20 +84,19 @@ class UpdateTest extends TestCase ->for(Nationality::factory()) ->for(Subscription::factory()->for(Fee::factory())) ->for(Country::factory()) - ->create(['nami_id' => 135]); + ->create(['nami_id' => 135]); } private function fakeRequest(): void { Http::fake(function ($request) { - if ($request->url() === app(FakeBackend::class)->singleMemberUrl(10, 135) && $request->method() === 'GET') { + if ($request->url() === app(FakeBackend::class)->singleMemberUrl(10, 135) && 'GET' === $request->method()) { return Http::response('{ "success": true, "data": {"missingkey": "missingvalue", "kontoverbindung": {"a": "b"} } }', 200); } - if ($request->url() === app(FakeBackend::class)->singleMemberUrl(10, 135) && $request->method() === 'PUT') { + if ($request->url() === app(FakeBackend::class)->singleMemberUrl(10, 135) && 'PUT' === $request->method()) { return Http::response('{ "success": true, "data": { "version": 44 } }', 200); } }); } - } diff --git a/tests/Feature/Membership/StoreTest.php b/tests/Feature/Membership/StoreTest.php index e9fadea4..a380bd90 100644 --- a/tests/Feature/Membership/StoreTest.php +++ b/tests/Feature/Membership/StoreTest.php @@ -8,14 +8,12 @@ use App\Member\Member; use App\Subactivity; use Carbon\Carbon; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; use Zoomyboy\LaravelNami\Fakes\MemberFake; use Zoomyboy\LaravelNami\Fakes\MembershipFake; class StoreTest extends TestCase { - use DatabaseTransactions; public function testItCanCreateAMembership(): void @@ -54,6 +52,4 @@ class StoreTest extends TestCase 'aktivBis' => null, ]); } - } - diff --git a/tests/Feature/Pdf/GenerateTest.php b/tests/Feature/Pdf/GenerateTest.php index c96143c6..373c0120 100644 --- a/tests/Feature/Pdf/GenerateTest.php +++ b/tests/Feature/Pdf/GenerateTest.php @@ -21,7 +21,6 @@ use Tests\TestCase; class GenerateTest extends TestCase { - use DatabaseTransactions; public function setUp(): void @@ -158,7 +157,7 @@ class GenerateTest extends TestCase $member = Member::find($urlId); $repo = app(PdfRepositoryFactory::class)->fromSingleRequest($type, $member); - if ($filename === null) { + if (null === $filename) { $this->assertNull($repo); return; @@ -188,14 +187,14 @@ class GenerateTest extends TestCase 'type' => $type, ]); - if ($filename === null) { + if (null === $filename) { $response->assertStatus(204); return; } $this->assertEquals('application/pdf', $response->headers->get('content-type')); - $this->assertEquals('inline; filename="' . $filename . '"', $response->headers->get('content-disposition')); + $this->assertEquals('inline; filename="'.$filename.'"', $response->headers->get('content-disposition')); } private function setupMembers(array $members): Collection @@ -212,5 +211,4 @@ class GenerateTest extends TestCase return $memberModel->load('payments'); }); } - } diff --git a/tests/Feature/Settings/GlobalSettingTest.php b/tests/Feature/Settings/GlobalSettingTest.php index c469f359..cea89dd1 100644 --- a/tests/Feature/Settings/GlobalSettingTest.php +++ b/tests/Feature/Settings/GlobalSettingTest.php @@ -4,12 +4,10 @@ namespace Tests\Feature\Settings; use App\Setting\GeneralSettings; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class GlobalSettingTest extends TestCase { - use DatabaseTransactions; public function testItLoadsGeneralSettings(): void @@ -21,7 +19,7 @@ class GlobalSettingTest extends TestCase $this->login()->init(); $response = $this->get('/setting'); - + $this->assertComponent('setting/Index', $response); $this->assertEquals(['bill'], $this->inertia($response, 'general.modules')); } @@ -32,8 +30,7 @@ class GlobalSettingTest extends TestCase $this->login()->init(); $response = $this->get('/setting'); - + $this->assertContains('bill', $this->inertia($response, 'options.modules')); } - } diff --git a/tests/Feature/UserLoginTest.php b/tests/Feature/UserLoginTest.php index dc4d4ca9..a2ea474b 100644 --- a/tests/Feature/UserLoginTest.php +++ b/tests/Feature/UserLoginTest.php @@ -2,19 +2,13 @@ namespace Tests\Feature; -use App\Setting\GeneralSettings; use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Http; use Tests\TestCase; -use Zoomyboy\LaravelNami\Backend\FakeBackend; class UserLoginTest extends TestCase { - use DatabaseTransactions; public function setUp(): void @@ -30,7 +24,7 @@ class UserLoginTest extends TestCase $this->post('/login', [ 'email' => 'mail@example.com', - 'password' => 'secret' + 'password' => 'secret', ]); $this->assertAuthenticated(); @@ -43,10 +37,9 @@ class UserLoginTest extends TestCase $this->post('/login', [ 'email' => 'mail@example.com', - 'password' => 'wrong' + 'password' => 'wrong', ])->assertRedirect('/'); $this->assertFalse(auth()->check()); } - } diff --git a/tests/Lib/TestsInertia.php b/tests/Lib/TestsInertia.php index f887b0ff..bcca1256 100644 --- a/tests/Lib/TestsInertia.php +++ b/tests/Lib/TestsInertia.php @@ -5,14 +5,11 @@ namespace Tests\Lib; use Illuminate\Testing\TestResponse; use PHPUnit\Framework\Assert as PHPUnit; -trait TestsInertia { - +trait TestsInertia +{ /** - * @param mixed $value - * @param TestResponse $response + * @param mixed $value * @param ?string $key - * - * @return void */ public function assertInertiaHas($value, TestResponse $response, ?string $key = null): void { @@ -33,8 +30,6 @@ trait TestsInertia { /** * @param mixed $should * @param mixed $is - * - * @return void */ public function assertInertiaDeepNest($should, $is): void { @@ -57,5 +52,4 @@ trait TestsInertia { { return data_get($response->viewData('page')['props'], $key); } - } diff --git a/tests/TestCase.php b/tests/TestCase.php index aadbce71..f22601c1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,7 +3,6 @@ namespace Tests; use App\Member\Member; -use App\Setting\GeneralSettings; use App\Setting\NamiSettings; use App\User; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; @@ -11,8 +10,6 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Testing\TestResponse; use Tests\Lib\TestsInertia; use Zoomyboy\LaravelNami\Authentication\Auth; -use Zoomyboy\LaravelNami\Backend\FakeBackend; -use Zoomyboy\LaravelNami\Nami; abstract class TestCase extends BaseTestCase { @@ -80,5 +77,4 @@ abstract class TestCase extends BaseTestCase return $this; } - } diff --git a/tests/Unit/InitializeGroupsTest.php b/tests/Unit/InitializeGroupsTest.php index 5940ff53..53a4d74c 100644 --- a/tests/Unit/InitializeGroupsTest.php +++ b/tests/Unit/InitializeGroupsTest.php @@ -5,7 +5,6 @@ namespace Tests\Unit; use App\Group as GroupModel; use App\Initialize\InitializeGroups; use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Support\Facades\Http; use PHPUnit\Framework\MockObject\Stub; use Tests\TestCase; use Zoomyboy\LaravelNami\Api; @@ -13,7 +12,6 @@ use Zoomyboy\LaravelNami\Group; class InitializeGroupsTest extends TestCase { - use DatabaseTransactions; private Stub $api; @@ -24,7 +22,7 @@ class InitializeGroupsTest extends TestCase $this->api = $this->createStub(Api::class); } - public function test_it_doesnt_initialize_groups_when_nothing_sent(): void + public function testItDoesntInitializeGroupsWhenNothingSent(): void { $this->api->method('groups')->willReturn(collect([])); @@ -34,13 +32,13 @@ class InitializeGroupsTest extends TestCase $this->assertDatabaseCount('groups', 0); } - public function test_it_synchs_a_group_with_a_single_node_and_no_children(): void + public function testItSynchsAGroupWithASingleNodeAndNoChildren(): void { $this->api->method('groups')->will($this->returnValueMap([ [ null, - collect([(new Group())->setParentId(null)->setId(150)->setName('lorem')]) - ] + collect([(new Group())->setParentId(null)->setId(150)->setName('lorem')]), + ], ])); $this->api->method('subgroupsOf')->willReturn(collect([])); @@ -49,7 +47,7 @@ class InitializeGroupsTest extends TestCase $this->assertDatabaseHas('groups', [ 'nami_id' => 150, 'name' => 'lorem', - 'parent_id' => null + 'parent_id' => null, ]); } @@ -59,8 +57,8 @@ class InitializeGroupsTest extends TestCase $this->api->method('groups')->will($this->returnValueMap([ [ null, - collect([(new Group())->setParentId(null)->setId(150)->setName('lorem')]) - ] + collect([(new Group())->setParentId(null)->setId(150)->setName('lorem')]), + ], ])); $this->api->method('subgroupsOf')->willReturn(collect([])); @@ -106,5 +104,4 @@ class InitializeGroupsTest extends TestCase 'parent_id' => GroupModel::firstWhere('nami_id', 150)->id, ]); } - }