From fa0703cefd0253877cbae60e56587e89fc7b2fa9 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Thu, 6 Jun 2024 20:00:38 +0200 Subject: [PATCH 1/5] build(deps-dev): add bladestan --- composer.json | 5 +- composer.lock | 165 +++++++++++++++++++++++++++++++++++++++++++++++++- phpstan.neon | 1 - 3 files changed, 168 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6af64290..00c132c5 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,10 @@ "pestphp/pest": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-livewire": "^2.0", - "phpunit/phpunit": "^10.0" + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan-beberlei-assert": "^1.1", + "phpunit/phpunit": "^10.0", + "tomasvotruba/bladestan": "^0.5.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 8563e8e6..84c6fbc3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "97faa44b39abeeaf3d8510641b88c4ec", + "content-hash": "77792597ca94508a25bd414fce094abb", "packages": [ { "name": "aws/aws-crt-php", @@ -11589,6 +11589,50 @@ ], "time": "2024-01-20T20:34:02+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "5b19a72c93e79bb0d410ac2cd55f02c4a6e0cfbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/5b19a72c93e79bb0d410ac2cd55f02c4a6e0cfbe", + "reference": "5b19a72c93e79bb0d410ac2cd55f02c4a6e0cfbe", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.6.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.0" + }, + "time": "2024-06-06T11:26:29+00:00" + }, { "name": "phpstan/phpdoc-parser", "version": "1.29.1", @@ -11694,6 +11738,56 @@ ], "time": "2024-06-06T12:19:22+00:00" }, + { + "name": "phpstan/phpstan-beberlei-assert", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-beberlei-assert.git", + "reference": "0918f2c71f93d44839b74fe3ba2682b2083a8729" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-beberlei-assert/zipball/0918f2c71f93d44839b74fe3ba2682b2083a8729", + "reference": "0918f2c71f93d44839b74fe3ba2682b2083a8729", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "beberlei/assert": "^3.3.0", + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan beberlei/assert extension", + "support": { + "issues": "https://github.com/phpstan/phpstan-beberlei-assert/issues", + "source": "https://github.com/phpstan/phpstan-beberlei-assert/tree/1.1.2" + }, + "time": "2023-09-04T12:13:01+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "10.1.14", @@ -13211,6 +13305,75 @@ } ], "time": "2024-03-03T12:36:25+00:00" + }, + { + "name": "tomasvotruba/bladestan", + "version": "0.5.0", + "source": { + "type": "git", + "url": "https://github.com/TomasVotruba/bladestan.git", + "reference": "593c05f8940981e6ca8860555e273d135cec2aa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TomasVotruba/bladestan/zipball/593c05f8940981e6ca8860555e273d135cec2aa6", + "reference": "593c05f8940981e6ca8860555e273d135cec2aa6", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^9.0 || ^10.0 || ^11.0", + "illuminate/filesystem": "^9.0 || ^10.0 || ^11.0", + "illuminate/view": "^9.0 || ^10.0 || ^11.0", + "php": "^8.1", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "laravel/framework": "^10.40", + "nikic/php-parser": "^4.18", + "phpunit/phpunit": "^10.0", + "rector/rector": "^0.19", + "symplify/easy-ci": "^11.3", + "symplify/easy-coding-standard": "^12.1", + "tomasvotruba/class-leak": "^0.2.6", + "tracy/tracy": "^2.9" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "config/extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "TomasVotruba\\Bladestan\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rule for static analysis of Blade templates", + "keywords": [ + "phpstan-extension", + "static analysis" + ], + "support": { + "issues": "https://github.com/TomasVotruba/bladestan/issues", + "source": "https://github.com/TomasVotruba/bladestan/tree/0.5.0" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2024-01-10T21:54:16+00:00" } ], "aliases": [], diff --git a/phpstan.neon b/phpstan.neon index 27af532a..2ea8bc12 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,4 @@ includes: - - vendor/larastan/larastan/extension.neon - phpstan-baseline.neon parameters: From fb9afb0b581331cd718cf7decc98043292edf540 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Thu, 6 Jun 2024 20:23:13 +0200 Subject: [PATCH 2/5] chore(BookingAdminController): remove unused show route --- app/Http/Controllers/Booking/BookingAdminController.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Http/Controllers/Booking/BookingAdminController.php b/app/Http/Controllers/Booking/BookingAdminController.php index af47db67..19af060d 100644 --- a/app/Http/Controllers/Booking/BookingAdminController.php +++ b/app/Http/Controllers/Booking/BookingAdminController.php @@ -119,11 +119,6 @@ public function store(StoreBooking $request): RedirectResponse return to_route('bookings.event.index', $event); } - public function show(Booking $booking): View - { - return view('booking.show', compact('booking')); - } - public function edit(Booking $booking): View|RedirectResponse { if ($booking->event->endEvent >= now()) { From 0dbba90c7de1a9ab7ddc8d93da2c7d5267cd0dce Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Thu, 6 Jun 2024 20:45:28 +0200 Subject: [PATCH 3/5] fix: fix even more issues after moving to native enums Closes #853, #854 --- resources/views/event/admin/import.blade.php | 4 ++-- resources/views/event/admin/overview.blade.php | 4 ++-- resources/views/event/admin/show.blade.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/views/event/admin/import.blade.php b/resources/views/event/admin/import.blade.php index 5fd2b878..3b8fd225 100644 --- a/resources/views/event/admin/import.blade.php +++ b/resources/views/event/admin/import.blade.php @@ -13,7 +13,7 @@ - @if ($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS) + @if ($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS->value) CTOT 1 - Airport 1 - CTOT 2 - Airport @@ -34,7 +34,7 @@ + href="{{ $event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS->value ? url('import_multi_flights_template.xlsx') : url('import_template.xlsx') }}"> Download template diff --git a/resources/views/event/admin/overview.blade.php b/resources/views/event/admin/overview.blade.php index 142718ff..5c734e8e 100644 --- a/resources/views/event/admin/overview.blade.php +++ b/resources/views/event/admin/overview.blade.php @@ -88,13 +88,13 @@ class="fa fa-envelope"> {{ __('Send mail to all') }}  - @if ($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS) + @if ($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS->value) {{ __('Assign Routes') }}  @endif diff --git a/resources/views/event/admin/show.blade.php b/resources/views/event/admin/show.blade.php index ea82776b..153e7194 100644 --- a/resources/views/event/admin/show.blade.php +++ b/resources/views/event/admin/show.blade.php @@ -30,7 +30,7 @@ - @if ($event->type->id != \App\Enums\EventType::MULTIFLIGHTS) + @if ($event->event_type_id != \App\Enums\EventType::MULTIFLIGHTS->value) {{--Departure Airport--}}
From 92ab5ac23e57c5334ce9ed1b44f9f2a4f18293c9 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Thu, 6 Jun 2024 21:24:46 +0200 Subject: [PATCH 4/5] refactor: fix phpstan issues --- app/Http/Controllers/Faq/FaqAdminController.php | 4 +++- app/Http/Livewire/Bookings.php | 12 ++++++++++-- resources/views/booking/edit.blade.php | 3 ++- resources/views/booking/edit_multiflights.blade.php | 3 ++- resources/views/booking/overview/default.blade.php | 3 +-- .../views/booking/overview/multiflights.blade.php | 3 +-- resources/views/livewire/bookings.blade.php | 4 ++-- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Faq/FaqAdminController.php b/app/Http/Controllers/Faq/FaqAdminController.php index b91324be..c3c48e20 100644 --- a/app/Http/Controllers/Faq/FaqAdminController.php +++ b/app/Http/Controllers/Faq/FaqAdminController.php @@ -27,7 +27,9 @@ public function index(): View public function create(): View { $faq = new Faq(); - return view('faq.admin.form', compact('faq')); + + $events = collect(); + return view('faq.admin.form', compact('faq', 'events')); } public function store(StoreFaq $request): RedirectResponse diff --git a/app/Http/Livewire/Bookings.php b/app/Http/Livewire/Bookings.php index 656fa503..78f9d709 100644 --- a/app/Http/Livewire/Bookings.php +++ b/app/Http/Livewire/Bookings.php @@ -61,10 +61,18 @@ public function render() abort_unless(auth()->check() && auth()->user()->isAdmin, 404); } - $this->booked = $this->bookings->where('status', BookingStatus::BOOKED->value)->count(); + $this->booked = $this->bookings->where('status', BookingStatus::BOOKED)->count(); $this->total = $this->bookings->count(); - return view('livewire.bookings'); + // https://github.com/TomasVotruba/bladestan/issues/65#issuecomment-1582383622 + return view('livewire.bookings', [ + 'event' => $this->event, + 'refreshInSeconds' => $this->refreshInSeconds, + 'bookings' => $this->bookings, + 'filter' => $this->filter, + 'total' => $this->total, + 'booked' => $this->booked, + ]); } } diff --git a/resources/views/booking/edit.blade.php b/resources/views/booking/edit.blade.php index b6e0a210..beead073 100644 --- a/resources/views/booking/edit.blade.php +++ b/resources/views/booking/edit.blade.php @@ -125,7 +125,8 @@ - {{ $booking->bookedBy ? 'Edit' : 'Confirm' }} Booking + + {{ $booking->status === \App\Enums\BookingStatus::RESERVED ? 'Confirm' : 'Edit' }} Booking @if ($booking->status === \App\Enums\BookingStatus::RESERVED) diff --git a/resources/views/booking/edit_multiflights.blade.php b/resources/views/booking/edit_multiflights.blade.php index 2510e9f1..7265a0ff 100644 --- a/resources/views/booking/edit_multiflights.blade.php +++ b/resources/views/booking/edit_multiflights.blade.php @@ -106,7 +106,8 @@ - {{ $booking->bookedBy ? 'Edit' : 'Confirm' }} Booking + + {{ $booking->status === \App\Enums\BookingStatus::RESERVED ? 'Confirm' : 'Edit' }} Booking @if ($booking->status === \App\Enums\BookingStatus::RESERVED) diff --git a/resources/views/booking/overview/default.blade.php b/resources/views/booking/overview/default.blade.php index 461a031f..4dc31c61 100644 --- a/resources/views/booking/overview/default.blade.php +++ b/resources/views/booking/overview/default.blade.php @@ -70,8 +70,7 @@ {{-- Check if user already has a booking --}} @if ( $booking->event->multiple_bookings_allowed || - (!$booking->event->multiple_bookings_allowed && - !auth()->user()->bookings->where('event_id', $event->id)->first())) + auth()->user()->bookings->where('event_id', $booking->event->id)->isEmpty()) {{-- Check if user already has a booking, and only 1 is allowed --}} BOOK NOW diff --git a/resources/views/booking/overview/multiflights.blade.php b/resources/views/booking/overview/multiflights.blade.php index 16fbbcdd..b5febe96 100644 --- a/resources/views/booking/overview/multiflights.blade.php +++ b/resources/views/booking/overview/multiflights.blade.php @@ -53,8 +53,7 @@ {{-- Check if user already has a booking --}} @if ( $booking->event->multiple_bookings_allowed || - (!$booking->event->multiple_bookings_allowed && - !auth()->user()->bookings->where('event_id', $event->id)->first())) + auth()->user()->bookings->where('event_id', $booking->event->id)->isEmpty()) {{-- Check if user already has a booking, and only 1 is allowed --}} BOOK NOW diff --git a/resources/views/livewire/bookings.blade.php b/resources/views/livewire/bookings.blade.php index 3c8b6201..cdc757d3 100644 --- a/resources/views/livewire/bookings.blade.php +++ b/resources/views/livewire/bookings.blade.php @@ -44,9 +44,9 @@ class="fa fa-plus">

@include('layouts.alert') @if($event->startBooking <= now() || auth()->check() && auth()->user()->isAdmin) - Flights available: {{ $total - $booked }} / {{ $total }} + Flights available: {{ strval($total - $booked) }} / {{ $total }} - @if($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS) + @if($event->event_type_id == \App\Enums\EventType::MULTIFLIGHTS->value) @include('booking.overview.multiflights') @else @include('booking.overview.default') From 550f665bd5b74ceb5df694f0ed79aecf870c0f49 Mon Sep 17 00:00:00 2001 From: Dave Roverts Date: Thu, 6 Jun 2024 21:29:50 +0200 Subject: [PATCH 5/5] ci(ci): always run ci on all pull requests --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 940c76a5..5b028b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: [main, beta, alpha] pull_request: - branches: [main, beta, alpha] jobs: test-php-mysql: name: Test PHP ${{ matrix.php-versions }} (${{ matrix.stability }}) + Node ${{ matrix.node }} + ${{ matrix.os }} with MySQL