diff --git a/.gitignore b/.gitignore index 5e16aec8..8e6694da 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ _ide_helper*\.php \.phpstorm\.meta\.php .phpunit.result.cache +.phpunit.cache/test-results diff --git a/app/Enums/AirportView.php b/app/Enums/AirportView.php index 980e2275..b318201c 100644 --- a/app/Enums/AirportView.php +++ b/app/Enums/AirportView.php @@ -2,16 +2,9 @@ namespace App\Enums; -use BenSampo\Enum\Enum; - -/** - * @method static static NAME() - * @method static static ICAO() - * @method static static IATA() - */ -final class AirportView extends Enum +enum AirportView: int { - public const NAME = 0; - public const ICAO = 1; - public const IATA = 2; + case NAME = 0; + case ICAO = 1; + case IATA = 2; } diff --git a/app/Enums/BookingStatus.php b/app/Enums/BookingStatus.php index 7c20bf46..4d552e0c 100644 --- a/app/Enums/BookingStatus.php +++ b/app/Enums/BookingStatus.php @@ -2,16 +2,9 @@ namespace App\Enums; -use BenSampo\Enum\Enum; - -/** - * @method static static UNASSIGNED() - * @method static static RESERVED() - * @method static static BOOKED() - */ -final class BookingStatus extends Enum +enum BookingStatus: int { - public const UNASSIGNED = 0; - public const RESERVED = 1; - public const BOOKED = 2; + case UNASSIGNED = 0; + case RESERVED = 1; + case BOOKED = 2; } diff --git a/app/Enums/EventType.php b/app/Enums/EventType.php index 928c3252..42d223ae 100644 --- a/app/Enums/EventType.php +++ b/app/Enums/EventType.php @@ -2,20 +2,11 @@ namespace App\Enums; -use BenSampo\Enum\Enum; - -/** - * @method static static ONEWAY() - * @method static static CITYPAIR() - * @method static static FLYIN() - * @method static static GROUPFLIGHT() - * @method static static MULTIFLIGHTS() - */ -final class EventType extends Enum +enum EventType: int { - public const ONEWAY = 1; - public const CITYPAIR = 2; - public const FLYIN = 3; - public const GROUPFLIGHT = 4; - public const MULTIFLIGHTS = 5; + case ONEWAY = 1; + case CITYPAIR = 2; + case FLYIN = 3; + case GROUPFLIGHT = 4; + case MULTIFLIGHTS = 5; } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8e7fbd1b..d92e585d 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -32,7 +32,7 @@ class Handler extends ExceptionHandler * * @return void */ - public function register() + public function register(): void { $this->reportable(function (Throwable $e) { // diff --git a/app/Exports/BookingsExport.php b/app/Exports/BookingsExport.php index d0a978ef..926e5b4b 100644 --- a/app/Exports/BookingsExport.php +++ b/app/Exports/BookingsExport.php @@ -27,12 +27,12 @@ public function __construct(public Event $event, public ?bool $vacc) */ public function collection() { - return $this->event->bookings()->with('flights')->whereStatus(BookingStatus::BOOKED)->get(); + return $this->event->bookings()->with('flights')->whereStatus(BookingStatus::BOOKED->value)->get(); } public function map($booking): array { - if ($this->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($this->event->event_type_id == EventType::MULTIFLIGHTS->value) { $flight1 = $booking->flights()->first(); $flight2 = $booking->flights()->whereKeyNot($flight1->id)->first(); if ($this->vacc) { @@ -74,7 +74,7 @@ public function map($booking): array public function columnFormats(): array { - if ($this->event->event_type_id == EventType::MULTIFLIGHTS && !$this->vacc) { + if ($this->event->event_type_id == EventType::MULTIFLIGHTS->value && !$this->vacc) { return [ 'E' => NumberFormat::FORMAT_DATE_TIME4, 'G' => NumberFormat::FORMAT_DATE_TIME4, diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index bf2f8570..40fbc920 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -100,7 +100,7 @@ protected function verifyLogin(Request $request) $booking = Booking::whereUuid(session('booking'))->first(); session()->forget('booking'); if (!empty($booking)) { - if ($booking->status !== BookingStatus::BOOKED) { + if ($booking->status !== BookingStatus::BOOKED->value) { return to_route('bookings.edit', $booking); } return to_route('bookings.show', $booking); diff --git a/app/Http/Controllers/Booking/BookingAdminController.php b/app/Http/Controllers/Booking/BookingAdminController.php index 86a10edb..af47db67 100644 --- a/app/Http/Controllers/Booking/BookingAdminController.php +++ b/app/Http/Controllers/Booking/BookingAdminController.php @@ -263,7 +263,7 @@ public function adminAutoAssign(AutoAssign $request, Event $event): RedirectResp }]); if (!$request->checkAssignAllFlights) { - $bookings = $bookings->where('status', BookingStatus::BOOKED); + $bookings = $bookings->where('status', BookingStatus::BOOKED->value); } $bookings = $bookings->get(); $count = 0; diff --git a/app/Http/Controllers/Booking/BookingController.php b/app/Http/Controllers/Booking/BookingController.php index 700264c7..a3ea9cde 100644 --- a/app/Http/Controllers/Booking/BookingController.php +++ b/app/Http/Controllers/Booking/BookingController.php @@ -24,7 +24,7 @@ public function index(Request $request, Event $event): View|RedirectResponse public function show(Booking $booking): View { - if ($booking->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($booking->event->event_type_id == EventType::MULTIFLIGHTS->value) { return view('booking.show_multiflights', compact('booking')); } $flight = $booking->flights->first(); @@ -35,21 +35,21 @@ public function show(Booking $booking): View public function edit(Booking $booking): View|RedirectResponse { // Check if the booking has already been booked or reserved - if ($booking->status !== BookingStatus::UNASSIGNED) { + if ($booking->status !== BookingStatus::UNASSIGNED->value) { // Check if current user has booked/reserved if ($booking->user_id == auth()->id()) { - if ($booking->status == BookingStatus::BOOKED && !$booking->is_editable) { + if ($booking->status == BookingStatus::BOOKED->value && !$booking->is_editable) { flashMessage('info', __('Danger'), __('You cannot edit the booking!')); return to_route('bookings.event.index', $booking->event); } - if ($booking->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($booking->event->event_type_id == EventType::MULTIFLIGHTS->value) { return view('booking.edit_multiflights', compact('booking')); } $flight = $booking->flights->first(); return view('booking.edit', compact('booking', 'flight')); } else { // Check if the booking has already been reserved - if ($booking->status === BookingStatus::RESERVED) { + if ($booking->status === BookingStatus::RESERVED->value) { flashMessage( 'danger', __('Warning'), @@ -74,7 +74,7 @@ public function edit(Booking $booking): View|RedirectResponse 'event_id', $booking->event_id ) - ->where('status', BookingStatus::BOOKED) + ->where('status', BookingStatus::BOOKED->value) ->first() ) { flashMessage('danger!', __('Warning'), __('You already have a booking!')); @@ -82,7 +82,7 @@ public function edit(Booking $booking): View|RedirectResponse } // If user already has another reservation open if (auth()->user()->bookings->where('event_id', $booking->event_id) - ->where('status', BookingStatus::RESERVED) + ->where('status', BookingStatus::RESERVED->value) ->first() ) { flashMessage('danger', __('Warning'), __('You already have a reservation! Please cancel or book that flight first.')); @@ -96,14 +96,14 @@ public function edit(Booking $booking): View|RedirectResponse ->by(auth()->user()) ->on($booking) ->log('Flight reserved'); - $booking->status = BookingStatus::RESERVED; + $booking->status = BookingStatus::RESERVED->value; $booking->user()->associate(auth()->user())->save(); flashMessage( 'info', __('Slot reserved'), __('Slot remains reserved until :time', ['time' => $booking->updated_at->addMinutes(10)->format('Hi') . 'z']) ); - if ($booking->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($booking->event->event_type_id == EventType::MULTIFLIGHTS->value) { return view('booking.edit_multiflights', compact('booking')); } $flight = $booking->flights->first(); @@ -146,8 +146,8 @@ public function update(UpdateBooking $request, Booking $booking): RedirectRespon ); } - $booking->status = BookingStatus::BOOKED; - if ($booking->getOriginal('status') === BookingStatus::RESERVED) { + $booking->status = BookingStatus::BOOKED->value; + if ($booking->getOriginal('status') === BookingStatus::RESERVED->value) { $booking->save(); event(new BookingConfirmed($booking)); if (!Str::contains(config('mail.default'), ['log', 'array'])) { @@ -219,7 +219,7 @@ public function cancel(Booking $booking): RedirectResponse ]); } - if ($booking->status === BookingStatus::BOOKED) { + if ($booking->status === BookingStatus::BOOKED->value) { event(new BookingCancelled($booking, auth()->user())); $title = __('Booking cancelled!'); $message = __('Booking has been cancelled!'); @@ -228,7 +228,7 @@ public function cancel(Booking $booking): RedirectResponse $message = __('Slot is now free to use again'); } - $booking->status = BookingStatus::UNASSIGNED; + $booking->status = BookingStatus::UNASSIGNED->value; flashMessage('info', $title, $message); $booking->user()->dissociate()->save(); return to_route('bookings.event.index', $booking->event); diff --git a/app/Http/Controllers/Event/EventAdminController.php b/app/Http/Controllers/Event/EventAdminController.php index dba71e59..5b71b606 100644 --- a/app/Http/Controllers/Event/EventAdminController.php +++ b/app/Http/Controllers/Event/EventAdminController.php @@ -143,7 +143,7 @@ public function sendEmail(SendEmail $request, Event $event): JsonResponse|Redire /* @var User $users */ $users = User::whereHas('bookings', function (Builder $query) use ($event) { $query->where('event_id', $event->id); - $query->where('status', BookingStatus::BOOKED); + $query->where('status', BookingStatus::BOOKED->value); })->get(); event(new EventBulkEmail($event, $request->all(), $users)); flashMessage('success', __('Done'), __('Bulk E-mail has been sent to :count people!', ['count' => $users->count()])); @@ -155,7 +155,7 @@ public function sendFinalInformationMail(Request $request, Event $event): Redire { $bookings = $event->bookings() ->with(['user', 'flights']) - ->where('status', BookingStatus::BOOKED) + ->where('status', BookingStatus::BOOKED->value) ->get(); if ($request->testmode) { diff --git a/app/Http/Livewire/Bookings.php b/app/Http/Livewire/Bookings.php index 24a272f5..656fa503 100644 --- a/app/Http/Livewire/Bookings.php +++ b/app/Http/Livewire/Bookings.php @@ -15,12 +15,12 @@ class Bookings extends Component public int $total = 0; public int $booked = 0; - public function filter($filter) + public function filter($filter): void { $this->filter = strtolower($filter); } - public function mount() + public function mount(): void { // Only enable polling if event is 'active' if (now()->between($this->event->startBooking, $this->event->endEvent)) { @@ -61,7 +61,7 @@ public function render() abort_unless(auth()->check() && auth()->user()->isAdmin, 404); } - $this->booked = $this->bookings->where('status', BookingStatus::BOOKED)->count(); + $this->booked = $this->bookings->where('status', BookingStatus::BOOKED->value)->count(); $this->total = $this->bookings->count(); diff --git a/app/Http/Resources/EventResource.php b/app/Http/Resources/EventResource.php index 6fd97b21..342e101e 100644 --- a/app/Http/Resources/EventResource.php +++ b/app/Http/Resources/EventResource.php @@ -19,7 +19,7 @@ class EventResource extends JsonResource public function toArray($request) { $total = $this->bookings->count(); - $booked = $total - $this->bookings->where('status', BookingStatus::BOOKED)->count(); + $booked = $total - $this->bookings->where('status', BookingStatus::BOOKED->value)->count(); return [ 'id' => $this->id, 'event_type' => $this->type->name, diff --git a/app/Imports/BookingsImport.php b/app/Imports/BookingsImport.php index 7b703e74..e3c4f4b8 100644 --- a/app/Imports/BookingsImport.php +++ b/app/Imports/BookingsImport.php @@ -28,7 +28,7 @@ public function __construct(public Event $event) * * @return \Illuminate\Database\Eloquent\Model|null */ - public function model(array $row) + public function model(array $row): void { $editable = true; if (!empty($row['call_sign']) && !empty($row['aircraft_type'])) { @@ -41,7 +41,7 @@ public function model(array $row) 'acType' => $row['aircraft_type'] ?? null, ]); - if ($this->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($this->event->event_type_id == EventType::MULTIFLIGHTS->value) { $airport1 = $this->getAirport($row['airport_1']); $airport2 = $this->getAirport($row['airport_2']); $airport3 = $this->getAirport($row['airport_3']); @@ -89,7 +89,7 @@ public function chunkSize(): int public function rules(): array { - if ($this->event->event_type_id == EventType::MULTIFLIGHTS) { + if ($this->event->event_type_id == EventType::MULTIFLIGHTS->value) { return [ 'airport_1' => 'exists:airports,icao', 'airport_2' => 'exists:airports,icao', diff --git a/app/Imports/FlightRouteAssign.php b/app/Imports/FlightRouteAssign.php index 09e14f06..89cc9bb2 100644 --- a/app/Imports/FlightRouteAssign.php +++ b/app/Imports/FlightRouteAssign.php @@ -14,7 +14,7 @@ class FlightRouteAssign implements ToCollection, WithHeadingRow, WithValidation { use Importable; - public function collection(Collection $rows) + public function collection(Collection $rows): void { foreach ($rows as $row) { $from = $this->getAirport($row['from']); diff --git a/app/Jobs/EventCleanupReservationsJob.php b/app/Jobs/EventCleanupReservationsJob.php index 4f5da7e1..219c7ac7 100644 --- a/app/Jobs/EventCleanupReservationsJob.php +++ b/app/Jobs/EventCleanupReservationsJob.php @@ -33,13 +33,13 @@ public function __construct(public Event $event) * * @return void */ - public function handle() + public function handle(): void { $this->event->bookings() - ->whereStatus(BookingStatus::RESERVED) + ->whereStatus(BookingStatus::RESERVED->value) ->each(function (Booking $booking) { if (now()->greaterThanOrEqualTo($booking->updated_at->addMinutes(10))) { - $booking->status = BookingStatus::UNASSIGNED; + $booking->status = BookingStatus::UNASSIGNED->value; $booking->user_id = null; $booking->save(); } diff --git a/app/Jobs/ImportAirportsJob.php b/app/Jobs/ImportAirportsJob.php index fe71bfa4..40f54795 100644 --- a/app/Jobs/ImportAirportsJob.php +++ b/app/Jobs/ImportAirportsJob.php @@ -33,7 +33,7 @@ public function __construct() * * @return void */ - public function handle() + public function handle(): void { $file = 'import_' . time() . '.csv'; Storage::disk('local')->put( diff --git a/app/Listeners/SendBookingCancelledNotification.php b/app/Listeners/SendBookingCancelledNotification.php index 0583733e..8af77d18 100644 --- a/app/Listeners/SendBookingCancelledNotification.php +++ b/app/Listeners/SendBookingCancelledNotification.php @@ -24,7 +24,7 @@ public function __construct() * * @return void */ - public function handle(BookingCancelled $event) + public function handle(BookingCancelled $event): void { activity() ->by($event->user) diff --git a/app/Listeners/SendBookingChangedNotification.php b/app/Listeners/SendBookingChangedNotification.php index 7596a580..c205777c 100644 --- a/app/Listeners/SendBookingChangedNotification.php +++ b/app/Listeners/SendBookingChangedNotification.php @@ -23,7 +23,7 @@ public function __construct() * @param BookingChanged $event * @return void */ - public function handle(BookingChanged $event) + public function handle(BookingChanged $event): void { $event->booking->user->notify(new \App\Notifications\BookingChanged($event->booking, $event->changes)); } diff --git a/app/Listeners/SendBookingConfirmedNotification.php b/app/Listeners/SendBookingConfirmedNotification.php index fe733b14..50f1e9f4 100644 --- a/app/Listeners/SendBookingConfirmedNotification.php +++ b/app/Listeners/SendBookingConfirmedNotification.php @@ -23,7 +23,7 @@ public function __construct() * @param BookingConfirmed $event * @return void */ - public function handle(BookingConfirmed $event) + public function handle(BookingConfirmed $event): void { activity() ->by(auth()->user()) diff --git a/app/Listeners/SendBookingDeletedNotification.php b/app/Listeners/SendBookingDeletedNotification.php index 9ed7eebb..03f2fb99 100644 --- a/app/Listeners/SendBookingDeletedNotification.php +++ b/app/Listeners/SendBookingDeletedNotification.php @@ -23,7 +23,7 @@ public function __construct() * @param BookingDeleted $event * @return void */ - public function handle(BookingDeleted $event) + public function handle(BookingDeleted $event): void { $event->user->notify(new \App\Notifications\BookingDeleted($event->event)); } diff --git a/app/Listeners/SendEventBulkEmailNotification.php b/app/Listeners/SendEventBulkEmailNotification.php index 54591731..181bd7fe 100644 --- a/app/Listeners/SendEventBulkEmailNotification.php +++ b/app/Listeners/SendEventBulkEmailNotification.php @@ -24,7 +24,7 @@ public function __construct() * @param EventBulkEmail $event * @return void */ - public function handle(EventBulkEmail $event) + public function handle(EventBulkEmail $event): void { if (isset($event->request['testmode'])) { $log = 'Bulk E-mail test performed'; diff --git a/app/Listeners/SendEventFinalInformationNotification.php b/app/Listeners/SendEventFinalInformationNotification.php index 4d721e3b..115885a8 100644 --- a/app/Listeners/SendEventFinalInformationNotification.php +++ b/app/Listeners/SendEventFinalInformationNotification.php @@ -23,7 +23,7 @@ public function __construct() * @param EventFinalInformation $event * @return void */ - public function handle(EventFinalInformation $event) + public function handle(EventFinalInformation $event): void { if ($event->testUser) { activity() diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 1ee253fc..61b2d62b 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -108,11 +108,11 @@ public function getFullNameAttribute(): string if (!$this->id) { return '-'; } - if (auth()->check() && auth()->user()->airport_view !== AirportView::NAME) { + if (auth()->check() && auth()->user()->airport_view !== AirportView::NAME->value) { switch (auth()->user()->airport_view) { - case AirportView::ICAO: + case AirportView::ICAO->value: return '' . $this->icao . ''; - case AirportView::IATA: + case AirportView::IATA->value: return '' . $this->iata . ''; } } diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 60c2be79..5db07367 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -76,7 +76,7 @@ class Booking extends Model /** * Setup model event hooks */ - public static function boot() + public static function boot(): void { parent::boot(); self::creating(function ($model) { diff --git a/app/Models/Event.php b/app/Models/Event.php index 1dc829ef..0b72836b 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -158,8 +158,8 @@ public function getRouteKeyName(): string public function hasOrderButtons(): bool { return in_array($this->event_type_id, [ - \App\Enums\EventType::FLYIN, - \App\Enums\EventType::GROUPFLIGHT + \App\Enums\EventType::FLYIN->value, + \App\Enums\EventType::GROUPFLIGHT->value ]); } } diff --git a/app/Notifications/EventFinalInformation.php b/app/Notifications/EventFinalInformation.php index 6389c059..2523de10 100644 --- a/app/Notifications/EventFinalInformation.php +++ b/app/Notifications/EventFinalInformation.php @@ -44,7 +44,7 @@ public function toMail($notifiable) { $booking = $this->booking; $subject = $booking->event->name . ': ' . __('Booking confirmed'); - $template = $booking->event->event_type_id == EventType::MULTIFLIGHTS ? 'emails.event.finalInformation_multiflights' : 'emails.event.finalInformation'; + $template = $booking->event->event_type_id == EventType::MULTIFLIGHTS->value ? 'emails.event.finalInformation_multiflights' : 'emails.event.finalInformation'; $flight = $booking->flights->first() ?? null; return (new MailMessage()) ->subject($subject) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c744695a..0a7ad865 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -13,7 +13,7 @@ class AppServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { if (env('DB_LOWER_STRING_LENGTH')) { Schema::defaultStringLength(191); @@ -27,7 +27,7 @@ public function boot() * * @return void */ - public function register() + public function register(): void { // } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index e32e5135..523934eb 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -35,7 +35,7 @@ class AuthServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { $this->registerPolicies(); diff --git a/app/Providers/BreadcrumbsServiceProvider.php b/app/Providers/BreadcrumbsServiceProvider.php index 716ae057..6b04c284 100644 --- a/app/Providers/BreadcrumbsServiceProvider.php +++ b/app/Providers/BreadcrumbsServiceProvider.php @@ -11,7 +11,7 @@ class BreadcrumbsServiceProvider extends ServiceProvider * * @return void */ - public function register() + public function register(): void { // } @@ -21,7 +21,7 @@ public function register() * * @return void */ - public function boot() + public function boot(): void { require base_path('routes/breadcrumbs.php'); } diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 352cce44..9fca2faf 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -12,7 +12,7 @@ class BroadcastServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { Broadcast::routes(); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 4b1c3b8e..7668ba26 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -38,7 +38,7 @@ class EventServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { parent::boot(); diff --git a/app/Providers/HorizonServiceProvider.php b/app/Providers/HorizonServiceProvider.php index 8e6c82a2..aeb95ce8 100644 --- a/app/Providers/HorizonServiceProvider.php +++ b/app/Providers/HorizonServiceProvider.php @@ -13,7 +13,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider * * @return void */ - public function boot() + public function boot(): void { parent::boot(); diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index f34af12a..fab29bf1 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -24,7 +24,7 @@ class RouteServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { $this->configureRateLimiting(); diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php index de97cfb7..b782b731 100644 --- a/app/Providers/TelescopeServiceProvider.php +++ b/app/Providers/TelescopeServiceProvider.php @@ -14,7 +14,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider * * @return void */ - public function register() + public function register(): void { Telescope::night(); diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php index c06e9513..c8a54efa 100644 --- a/app/Providers/ViewServiceProvider.php +++ b/app/Providers/ViewServiceProvider.php @@ -11,7 +11,7 @@ class ViewServiceProvider extends ServiceProvider * * @return void */ - public function register() + public function register(): void { // } @@ -21,7 +21,7 @@ public function register() * * @return void */ - public function boot() + public function boot(): void { view()->composer('layouts.navbar', 'App\Http\View\Composers\EventsComposer'); } diff --git a/composer.json b/composer.json index 1b23a270..03eab373 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ "require": { "php": "^8.1", "aws/aws-sdk-php": "^3.209", - "bensampo/laravel-enum": "^6.0", "blade-ui-kit/blade-ui-kit": "^0.4", "bugsnag/bugsnag-laravel": "^2.26", "cviebrock/eloquent-sluggable": "^10.0", @@ -95,4 +94,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 8eb869f7..821e4bd6 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": "b278b5bfe2d320b0db4b9ee5b300272e", + "content-hash": "7ca62ea1a40aee5b2d6115cc2e285848", "packages": [ { "name": "aws/aws-crt-php", @@ -155,98 +155,6 @@ }, "time": "2024-02-05T19:05:28+00:00" }, - { - "name": "bensampo/laravel-enum", - "version": "v6.8.0", - "source": { - "type": "git", - "url": "https://github.com/BenSampo/laravel-enum.git", - "reference": "9e281ca6dc22f18c9f64257679bef3117aeb8835" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/BenSampo/laravel-enum/zipball/9e281ca6dc22f18c9f64257679bef3117aeb8835", - "reference": "9e281ca6dc22f18c9f64257679bef3117aeb8835", - "shasum": "" - }, - "require": { - "composer/class-map-generator": "^1", - "illuminate/contracts": "^9 || ^10", - "illuminate/support": "^9 || ^10", - "laminas/laminas-code": "^3.4 || ^4", - "nikic/php-parser": "^4.13", - "php": "^8" - }, - "require-dev": { - "doctrine/dbal": "^3.4", - "ergebnis/composer-normalize": "^2.28.3", - "larastan/larastan": "^2.6.3", - "mll-lab/php-cs-fixer-config": "^5.4", - "mockery/mockery": "^1.5", - "orchestra/testbench": "^7.6.1 || ^8", - "phpstan/extension-installer": "^1", - "phpstan/phpstan": "^1.8.2", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.1.1", - "phpunit/phpunit": "^9.5.21 || ^10", - "rector/rector": "^0.19", - "symplify/rule-doc-generator": "^11 || ^12" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "BenSampo\\Enum\\EnumServiceProvider" - ] - }, - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "BenSampo\\Enum\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ben Sampson", - "homepage": "https://sampo.co.uk", - "role": "Developer" - }, - { - "name": "Benedikt Franke", - "homepage": "https://franke.tech", - "role": "Developer" - } - ], - "description": "Simple, extensible and powerful enumeration implementation for Laravel.", - "homepage": "https://github.com/bensampo/laravel-enum", - "keywords": [ - "bensampo", - "enum", - "laravel", - "package", - "validation" - ], - "support": { - "issues": "https://github.com/BenSampo/laravel-enum/issues", - "source": "https://github.com/BenSampo/laravel-enum/tree/v6.8.0" - }, - "funding": [ - { - "url": "https://github.com/bensampo", - "type": "github" - } - ], - "time": "2024-01-12T15:33:22+00:00" - }, { "name": "blade-ui-kit/blade-ui-kit", "version": "0.4.0", @@ -850,150 +758,6 @@ ], "time": "2023-12-18T12:05:55+00:00" }, - { - "name": "composer/class-map-generator", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/composer/class-map-generator.git", - "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/953cc4ea32e0c31f2185549c7d216d7921f03da9", - "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9", - "shasum": "" - }, - "require": { - "composer/pcre": "^2.1 || ^3.1", - "php": "^7.2 || ^8.0", - "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" - }, - "require-dev": { - "phpstan/phpstan": "^1.6", - "phpstan/phpstan-deprecation-rules": "^1", - "phpstan/phpstan-phpunit": "^1", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/filesystem": "^5.4 || ^6", - "symfony/phpunit-bridge": "^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\ClassMapGenerator\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "https://seld.be" - } - ], - "description": "Utilities to scan PHP code and generate class maps.", - "keywords": [ - "classmap" - ], - "support": { - "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.1.0" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2023-06-30T13:58:57+00:00" - }, - { - "name": "composer/pcre", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/composer/pcre.git", - "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", - "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Pcre\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "PCRE wrapping library that offers type-safe preg_* replacements.", - "keywords": [ - "PCRE", - "preg", - "regex", - "regular expression" - ], - "support": { - "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.1" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2023-10-11T07:11:09+00:00" - }, { "name": "composer/semver", "version": "3.4.0", @@ -2584,69 +2348,6 @@ }, "time": "2021-10-08T21:21:46+00:00" }, - { - "name": "laminas/laminas-code", - "version": "4.13.0", - "source": { - "type": "git", - "url": "https://github.com/laminas/laminas-code.git", - "reference": "7353d4099ad5388e84737dd16994316a04f48dbf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-code/zipball/7353d4099ad5388e84737dd16994316a04f48dbf", - "reference": "7353d4099ad5388e84737dd16994316a04f48dbf", - "shasum": "" - }, - "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0.1", - "ext-phar": "*", - "laminas/laminas-coding-standard": "^2.5.0", - "laminas/laminas-stdlib": "^3.17.0", - "phpunit/phpunit": "^10.3.3", - "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.15.0" - }, - "suggest": { - "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", - "laminas/laminas-stdlib": "Laminas\\Stdlib component" - }, - "type": "library", - "autoload": { - "psr-4": { - "Laminas\\Code\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", - "homepage": "https://laminas.dev", - "keywords": [ - "code", - "laminas", - "laminasframework" - ], - "support": { - "chat": "https://laminas.dev/chat", - "docs": "https://docs.laminas.dev/laminas-code/", - "forum": "https://discourse.laminas.dev", - "issues": "https://github.com/laminas/laminas-code/issues", - "rss": "https://github.com/laminas/laminas-code/releases.atom", - "source": "https://github.com/laminas/laminas-code" - }, - "funding": [ - { - "url": "https://funding.communitybridge.org/projects/laminas-project", - "type": "community_bridge" - } - ], - "time": "2023-10-18T10:00:55+00:00" - }, { "name": "laravel/framework", "version": "v10.43.0", @@ -10199,6 +9900,150 @@ ], "time": "2024-02-06T13:50:28+00:00" }, + { + "name": "composer/class-map-generator", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/composer/class-map-generator.git", + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/953cc4ea32e0c31f2185549c7d216d7921f03da9", + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9", + "shasum": "" + }, + "require": { + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/filesystem": "^5.4 || ^6", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\ClassMapGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Utilities to scan PHP code and generate class maps.", + "keywords": [ + "classmap" + ], + "support": { + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.1.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-06-30T13:58:57+00:00" + }, + { + "name": "composer/pcre", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-10-11T07:11:09+00:00" + }, { "name": "fakerphp/faker", "version": "v1.23.1", diff --git a/routes/api.php b/routes/api.php index 1debbd3b..c2f0afff 100644 --- a/routes/api.php +++ b/routes/api.php @@ -39,7 +39,7 @@ }); Route::get('/events/{event}/bookings', function (Event $event) { - return new BookingsCollection($event->bookings->where('status', BookingStatus::BOOKED)); + return new BookingsCollection($event->bookings->where('status', BookingStatus::BOOKED->value)); }); Route::get('/events/{event}', function (Event $event) { diff --git a/tests/Feature/Jobs/EventCleanupReservationsJobTest.php b/tests/Feature/Jobs/EventCleanupReservationsJobTest.php index 5b10365b..7727b447 100644 --- a/tests/Feature/Jobs/EventCleanupReservationsJobTest.php +++ b/tests/Feature/Jobs/EventCleanupReservationsJobTest.php @@ -18,24 +18,24 @@ $booking = $event->bookings()->inRandomOrder()->first(); - $booking->status = BookingStatus::RESERVED; + $booking->status = BookingStatus::RESERVED->value; $booking->save(); - $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED)->get()); + $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED->value)->get()); EventCleanupReservationsJob::dispatch($event); - $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED)->get()); + $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED->value)->get()); $this->travel(9)->minutes(); EventCleanupReservationsJob::dispatch($event); - $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED)->get()); + $this->assertCount(1, $event->bookings()->whereStatus(BookingStatus::RESERVED->value)->get()); $this->travel(1)->minutes(); EventCleanupReservationsJob::dispatch($event); - $this->assertCount(0, $event->bookings()->whereStatus(BookingStatus::RESERVED)->get()); + $this->assertCount(0, $event->bookings()->whereStatus(BookingStatus::RESERVED->value)->get()); });