diff --git a/app/DTOs/MissingLivery.php b/app/DTOs/MissingLivery.php new file mode 100644 index 0000000..dcf58a2 --- /dev/null +++ b/app/DTOs/MissingLivery.php @@ -0,0 +1,13 @@ + $this->adminService->getMissingLiveries()->count(), + ]; + } + + function dashboard(){ + return inertia('Admin/Dashboard', [ + 'title' => 'Admin Control Panel', + 'userCount' => User::count(), + 'oneWeekUserGrowth' => User::where('created_at', '>=', Carbon::now()->subWeek())->count(), + 'flightCount' => UserFlight::count(), + 'oneWeekFlightGrowth' => UserFlight::where('created_at', '>=', Carbon::now()->subWeek())->count(), + 'latestUser' => User::latest()->first()->name, + ...$this->staticAdminData(), + ]); + } + + function reconcileMissingLiveries(){ + $missingLiveries = $this->adminService->getMissingLiveries(); + + return Inertia::render('Admin/MissingLiveries', [ + 'title' => $missingLiveries->count() . ' Missing Liveries', + 'missingLiveries' => $missingLiveries, + ...$this->staticAdminData(), + ]); + } + + public function ignoreMissingLivery(Request $request) + { + $validated = $request->validate([ + 'filename' => 'required|string', + ]); + + IgnoredMissingLivery::createOrFirst($validated); + + return back(); + } + +} diff --git a/app/Http/Controllers/FlightImportController.php b/app/Http/Controllers/FlightImportController.php index 0afb7b9..6b816e2 100644 --- a/app/Http/Controllers/FlightImportController.php +++ b/app/Http/Controllers/FlightImportController.php @@ -126,6 +126,18 @@ class FlightImportController extends Controller return $airlines; } + + public function showFr24Import() + { + if (Auth::user()->importedFlights()->exists()) { + return to_route('reconcile'); + } + + return Inertia::render('Fr24Import'); + } + + // FlightImportController.php + public function reconcile(Request $request) { $user = Auth::user(); @@ -133,35 +145,38 @@ class FlightImportController extends Controller $flightToReconcile = ImportedFlight::where('user_id', $user->id)->orderBy('date', 'asc')->first(); if (!$flightToReconcile) { - return null; + return to_route('import.fr24'); } - $date = null; - if ($flightToReconcile->date) { - $date = Carbon::createFromFormat('Y-m-d', $flightToReconcile->date)->format('Y-m-d'); - } + $date = $flightToReconcile->date + ? Carbon::createFromFormat('Y-m-d', $flightToReconcile->date)->format('Y-m-d') + : null; - - return [ - 'imported_flight_id' => $flightToReconcile->id, - 'flight_classes' => $this->selectOptions(FlightClass::class), - 'flight_reasons' => $this->selectOptions(FlightReason::class), - 'seat_types' => $this->selectOptions(SeatType::class), - 'flight_number' => $flightToReconcile->flight_number ?? '', - 'date' => $date ?? '', - 'dep_time' => $this->formatTime($flightToReconcile->dep_time), - 'arr_time' => $this->formatTime($flightToReconcile->arr_time), - 'duration' => $this->formatTime($flightToReconcile->duration), - 'registration' => $flightToReconcile->registration ?? '', - 'note' => $flightToReconcile->note ?? '', - 'flight_class' => $flightToReconcile->flight_class !== null ? (int) $flightToReconcile->flight_class : null, - 'seat_type' => $flightToReconcile->seat_type !== null ? (int) $flightToReconcile->seat_type : null, - 'flight_reason' => $flightToReconcile->flight_reason !== null ? (int) $flightToReconcile->flight_reason : null, - 'airline_options' => $this->getPossibleAirlines($flightToReconcile->airline ?? ''), - 'to_options' => $this->getPossibleAirports($flightToReconcile->to ?? ''), - 'from_options' => $this->getPossibleAirports($flightToReconcile->from ?? ''), - 'aircraft_options' => $this->getPossibleAircraft($flightToReconcile->aircraft ?? ''), + $flight = [ + 'imported_flight_id' => $flightToReconcile->id, + 'flight_classes' => $this->selectOptions(FlightClass::class), + 'flight_reasons' => $this->selectOptions(FlightReason::class), + 'seat_types' => $this->selectOptions(SeatType::class), + 'flight_number' => $flightToReconcile->flight_number ?? '', + 'date' => $date ?? '', + 'dep_time' => $this->formatTime($flightToReconcile->dep_time), + 'arr_time' => $this->formatTime($flightToReconcile->arr_time), + 'duration' => $this->formatTime($flightToReconcile->duration), + 'registration' => $flightToReconcile->registration ?? '', + 'note' => $flightToReconcile->note ?? '', + 'flight_class' => $flightToReconcile->flight_class !== null ? (int) $flightToReconcile->flight_class : null, + 'seat_type' => $flightToReconcile->seat_type !== null ? (int) $flightToReconcile->seat_type : null, + 'flight_reason' => $flightToReconcile->flight_reason !== null ? (int) $flightToReconcile->flight_reason : null, + 'airline_options' => $this->getPossibleAirlines($flightToReconcile->airline ?? ''), + 'to_options' => $this->getPossibleAirports($flightToReconcile->to ?? ''), + 'from_options' => $this->getPossibleAirports($flightToReconcile->from ?? ''), + 'aircraft_options' => $this->getPossibleAircraft($flightToReconcile->aircraft ?? ''), ]; + + return Inertia::render('ReconcileFlight', [ + 'flight' => $flight, + 'key' => $flight['imported_flight_id'], + ]); } public function save(Request $request) diff --git a/app/Http/Controllers/FlightProfileController.php b/app/Http/Controllers/FlightProfileController.php index 6fb80cf..fee5f72 100644 --- a/app/Http/Controllers/FlightProfileController.php +++ b/app/Http/Controllers/FlightProfileController.php @@ -17,7 +17,7 @@ class FlightProfileController extends Controller public function profileData(User $user, string $view, ?int $selectedFlightId = null) : array { return [ 'user' => $user, - 'canEdit' => auth()->check() && auth()->id() === $user->id, + 'canEdit' => (auth()->check() && auth()->id() === $user->id) || auth()->user()->hasRole('admin'), 'initialView' => $view, 'selectedFlightId' => $selectedFlightId, 'flight_api_url' => self::getUserFlightApiURL($user), diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 8e7480c..ce1c36b 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -35,6 +35,8 @@ class HandleInertiaRequests extends Middleware 'logo_api_url' => config('app.logo_api_url'), 'auth' => [ 'user' => $request->user(), + 'roles' => $request->user()?->getRoleNames() ?? [], + 'permissions' => $request->user()?->getAllPermissions()->pluck('name') ?? [], ], 'achievement_notifications' => fn() => $request->user() ? $request->user() diff --git a/app/Models/IgnoredMissingLivery.php b/app/Models/IgnoredMissingLivery.php new file mode 100644 index 0000000..36942fd --- /dev/null +++ b/app/Models/IgnoredMissingLivery.php @@ -0,0 +1,14 @@ + */ - use HasFactory, HasAchievements, HasApiTokens; - - + use HasFactory, HasAchievements, HasApiTokens, HasRoles; /** * Get the attributes that should be cast. diff --git a/app/Policies/UserFlightPolicy.php b/app/Policies/UserFlightPolicy.php index a6b5e98..72d6bf7 100644 --- a/app/Policies/UserFlightPolicy.php +++ b/app/Policies/UserFlightPolicy.php @@ -37,7 +37,7 @@ class UserFlightPolicy */ public function update(User $user, UserFlight $userFlight): bool { - return $user->id === $userFlight->user_id; + return $user->id === $userFlight->user_id || $user->hasRole('admin'); } /** diff --git a/app/Http/Controllers/AdminToolsController.php b/app/Services/AdminService.php similarity index 50% rename from app/Http/Controllers/AdminToolsController.php rename to app/Services/AdminService.php index 288b503..86f5f1f 100644 --- a/app/Http/Controllers/AdminToolsController.php +++ b/app/Services/AdminService.php @@ -1,26 +1,29 @@ */ + function getMissingLiveries(): Collection + { + /* $existingFiles = collect(glob(public_path('img/liveries/generated/*'))) + ->map(fn ($path) => pathinfo($path, PATHINFO_FILENAME)) + ->toArray();*/ -/* $existingFiles = collect(glob(public_path('img/liveries/generated/*'))) - ->map(fn ($path) => pathinfo($path, PATHINFO_FILENAME)) - ->toArray();*/ $existingFiles = collect(glob(Storage::disk('local')->path('images/liveries').'/*.png')) ->map(fn ($path) => pathinfo($path, PATHINFO_FILENAME)) ->toArray(); - - - $combos = \App\Models\UserFlight::with(['aircraft', 'airline']) + $combos = UserFlight::with(['aircraft', 'airline']) ->select('airline_id', 'aircraft_id') ->whereNotNull('airline_id') ->whereNotNull('aircraft_id') @@ -31,14 +34,15 @@ class AdminToolsController extends Controller 'airline_name' => $flight->airline->name, 'aircraft_display_name' => $flight->aircraft->display_name, 'filename' => $flight->airline->internal_name . '_' . $flight->aircraft->designator, + 'clipboard_text' => $flight->airline->name . ' ' . $flight->aircraft->display_name_short, ]) - ->filter(fn ($combo) => !in_array($combo['filename'], $existingFiles)) + ->filter(fn ($combo) => !in_array($combo['filename'], $existingFiles)); + + $ignoredFiles = IgnoredMissingLivery::whereIn('filename', $combos->pluck('filename'))->pluck('filename')->toArray(); + + return $combos + ->filter(fn ($combo) => !in_array($combo['filename'], $ignoredFiles)) ->sortBy('airline_name') ->values(); - - return response()->json([ - 'count' => $combos->count(), - 'liveries' => $combos, - ]); } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 0e21cf2..7271f0d 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -16,7 +16,11 @@ return Application::configure(basePath: dirname(__DIR__)) \App\Http\Middleware\HandleInertiaRequests::class, \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class, ]); - + $middleware->alias([ + 'role' => \Spatie\Permission\Middleware\RoleMiddleware::class, + 'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class, + 'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class, + ]); // }) ->withExceptions(function (Exceptions $exceptions): void { diff --git a/composer.json b/composer.json index e290b5a..f8a7759 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "laravel/framework": "^13.0", "laravel/sanctum": "^4.0", "laravel/tinker": "^3.0", + "spatie/laravel-permission": "^8.0", "tightenco/ziggy": "^2.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 1feb9f9..ccd5968 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": "0e560320885031dd36bb08bb44fe05d4", + "content-hash": "2fab3a0703fff56cedb9d4c9b650e2fc", "packages": [ { "name": "brick/math", @@ -3433,6 +3433,154 @@ }, "time": "2025-12-14T04:43:48+00:00" }, + { + "name": "spatie/laravel-package-tools", + "version": "1.93.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "d5552849801f2642aea710557463234b59ef65eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/d5552849801f2642aea710557463234b59ef65eb", + "reference": "d5552849801f2642aea710557463234b59ef65eb", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0|^12.0|^13.0", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^8.0|^9.2|^10.0|^11.0", + "pestphp/pest": "^2.1|^3.1|^4.0", + "phpunit/php-code-coverage": "^10.0|^11.0|^12.0", + "phpunit/phpunit": "^10.5|^11.5|^12.5", + "spatie/pest-plugin-test-time": "^2.2|^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.93.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-05-19T14:06:37+00:00" + }, + { + "name": "spatie/laravel-permission", + "version": "8.0.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-permission.git", + "reference": "70a6ab04108616b438e0839598f473b513281644" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/70a6ab04108616b438e0839598f473b513281644", + "reference": "70a6ab04108616b438e0839598f473b513281644", + "shasum": "" + }, + "require": { + "illuminate/auth": "^12.0|^13.0", + "illuminate/container": "^12.0|^13.0", + "illuminate/contracts": "^12.0|^13.0", + "illuminate/database": "^12.0|^13.0", + "php": "^8.3", + "spatie/laravel-package-tools": "^1.0" + }, + "require-dev": { + "larastan/larastan": "^3.9", + "laravel/passport": "^13.0", + "laravel/pint": "^1.0", + "orchestra/testbench": "^10.0|^11.0", + "pestphp/pest": "^3.0|^4.0", + "pestphp/pest-plugin-laravel": "^3.0|^4.1", + "phpstan/phpstan": "^2.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Permission\\PermissionServiceProvider" + ] + }, + "branch-alias": { + "dev-main": "8.x-dev", + "dev-master": "8.x-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Spatie\\Permission\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Permission handling for Laravel 12 and up", + "homepage": "https://github.com/spatie/laravel-permission", + "keywords": [ + "acl", + "laravel", + "permission", + "permissions", + "rbac", + "roles", + "security", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-permission/issues", + "source": "https://github.com/spatie/laravel-permission/tree/8.0.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-05-30T19:30:22+00:00" + }, { "name": "symfony/clock", "version": "v8.0.0", diff --git a/config/permission.php b/config/permission.php new file mode 100644 index 0000000..8f1f452 --- /dev/null +++ b/config/permission.php @@ -0,0 +1,219 @@ + [ + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * Eloquent model should be used to retrieve your permissions. Of course, it + * is often just the "Permission" model but you may use whatever you like. + * + * The model you want to use as a Permission model needs to implement the + * `Spatie\Permission\Contracts\Permission` contract. + */ + + 'permission' => Permission::class, + + /* + * When using the "HasRoles" trait from this package, we need to know which + * Eloquent model should be used to retrieve your roles. Of course, it + * is often just the "Role" model but you may use whatever you like. + * + * The model you want to use as a Role model needs to implement the + * `Spatie\Permission\Contracts\Role` contract. + */ + + 'role' => Role::class, + + /* + * When using the "Teams" feature from this package, we need to know which + * Eloquent model should be used to retrieve your teams. Of course, it + * is often just the "Team" model but you may use whatever you like. + */ + 'team' => null, + + /* + * When using the "HasModels" trait and passing raw IDs to syncModels, + * attachModels, or detachModels, this model class will be used to + * resolve those IDs. If null, defaults to the guard's model. + */ + 'default_model' => null, + ], + + 'table_names' => [ + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'roles' => 'roles', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your permissions. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'permissions' => 'permissions', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your models permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_permissions' => 'model_has_permissions', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your models roles. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_roles' => 'model_has_roles', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'role_has_permissions' => 'role_has_permissions', + ], + + 'column_names' => [ + /* + * Change this if you want to name the related pivots other than defaults + */ + 'role_pivot_key' => null, // default 'role_id', + 'permission_pivot_key' => null, // default 'permission_id', + + /* + * Change this if you want to name the related model primary key other than + * `model_id`. + * + * For example, this would be nice if your primary keys are all UUIDs. In + * that case, name this `model_uuid`. + */ + + 'model_morph_key' => 'model_id', + + /* + * Change this if you want to use the teams feature and your related model's + * foreign key is other than `team_id`. + */ + + 'team_foreign_key' => 'team_id', + ], + + /* + * When set to true, the method for checking permissions will be registered on the gate. + * Set this to false if you want to implement custom logic for checking permissions. + */ + + 'register_permission_check_method' => true, + + /* + * When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered + * this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated + * NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it. + */ + 'register_octane_reset_listener' => false, + + /* + * Events will fire when a role or permission is assigned/unassigned: + * \Spatie\Permission\Events\RoleAttachedEvent + * \Spatie\Permission\Events\RoleDetachedEvent + * \Spatie\Permission\Events\PermissionAttachedEvent + * \Spatie\Permission\Events\PermissionDetachedEvent + * + * To enable, set to true, and then create listeners to watch these events. + */ + 'events_enabled' => false, + + /* + * Teams Feature. + * When set to true the package implements teams using the 'team_foreign_key'. + * If you want the migrations to register the 'team_foreign_key', you must + * set this to true before doing the migration. + * If you already did the migration then you must make a new migration to also + * add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions' + * (view the latest version of this package's migration file) + */ + + 'teams' => false, + + /* + * The class to use to resolve the permissions team id + */ + 'team_resolver' => DefaultTeamResolver::class, + + /* + * Passport Client Credentials Grant + * When set to true the package will use Passports Client to check permissions + */ + + 'use_passport_client_credentials' => false, + + /* + * When set to true, the required permission names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_permission_in_exception' => false, + + /* + * When set to true, the required role names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_role_in_exception' => false, + + /* + * By default wildcard permission lookups are disabled. + * See documentation to understand supported syntax. + */ + + 'enable_wildcard_permission' => false, + + /* + * The class to use for interpreting wildcard permissions. + * If you need to modify delimiters, override the class and specify its name here. + */ + // 'wildcard_permission' => Spatie\Permission\WildcardPermission::class, + + /* Cache-specific settings */ + + 'cache' => [ + + /* + * By default all permissions are cached for 24 hours to speed up performance. + * When permissions or roles are updated the cache is flushed automatically. + */ + + 'expiration_time' => DateInterval::createFromDateString('24 hours'), + + /* + * The cache key used to store all permissions. + */ + + 'key' => 'spatie.permission.cache', + + /* + * You may optionally indicate a specific cache driver to use for permission and + * role caching using any of the `store` drivers listed in the cache.php config + * file. Using 'default' here means to use the `default` set in cache.php. + */ + + 'store' => 'default', + ], +]; diff --git a/database/migrations/2026_06_13_140854_create_permission_tables.php b/database/migrations/2026_06_13_140854_create_permission_tables.php new file mode 100644 index 0000000..8986275 --- /dev/null +++ b/database/migrations/2026_06_13_140854_create_permission_tables.php @@ -0,0 +1,137 @@ +id(); // permission id + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + + $table->unique(['name', 'guard_name']); + }); + + /** + * See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered. + */ + Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) { + $table->id(); // role id + if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing + $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); + $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); + } + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + if ($teams || config('permission.testing')) { + $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); + } else { + $table->unique(['name', 'guard_name']); + } + }); + + Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) { + $table->unsignedBigInteger($pivotPermission); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign($pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->cascadeOnDelete(); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } else { + $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } + }); + + Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { + $table->unsignedBigInteger($pivotRole); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign($pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->cascadeOnDelete(); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } else { + $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } + }); + + Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) { + $table->unsignedBigInteger($pivotPermission); + $table->unsignedBigInteger($pivotRole); + + $table->foreign($pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->cascadeOnDelete(); + + $table->foreign($pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->cascadeOnDelete(); + + $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $tableNames = config('permission.table_names'); + + throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + + Schema::dropIfExists($tableNames['role_has_permissions']); + Schema::dropIfExists($tableNames['model_has_roles']); + Schema::dropIfExists($tableNames['model_has_permissions']); + Schema::dropIfExists($tableNames['roles']); + Schema::dropIfExists($tableNames['permissions']); + } +}; diff --git a/database/migrations/2026_06_13_141036_create_admin_users.php b/database/migrations/2026_06_13_141036_create_admin_users.php new file mode 100644 index 0000000..5000433 --- /dev/null +++ b/database/migrations/2026_06_13_141036_create_admin_users.php @@ -0,0 +1,34 @@ + 'admin']); + $permission = Permission::create(['name' => 'reconcile_missing_liveries']); + + $role->givePermissionTo($permission); + + $user = User::whereName('Josh')->first(); + + $user->assignRole($role); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + + } +}; diff --git a/database/migrations/2026_06_13_153654_create_ignored_missing_liveries_table.php b/database/migrations/2026_06_13_153654_create_ignored_missing_liveries_table.php new file mode 100644 index 0000000..c75d1e6 --- /dev/null +++ b/database/migrations/2026_06_13_153654_create_ignored_missing_liveries_table.php @@ -0,0 +1,27 @@ +id(); + $table->string('filename')->unique()->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('ignored_missing_liveries'); + } +}; diff --git a/database/migrations/2026_06_14_060343_add_user_settings.php b/database/migrations/2026_06_14_060343_add_user_settings.php new file mode 100644 index 0000000..88fa2f3 --- /dev/null +++ b/database/migrations/2026_06_14_060343_add_user_settings.php @@ -0,0 +1,24 @@ + +defineProps<{ + label: string; + count: number; + weeklyGrowth: number; + icon: string; +}>(); + + + diff --git a/resources/js/Components/Admin/MissingLiveryCard.vue b/resources/js/Components/Admin/MissingLiveryCard.vue new file mode 100644 index 0000000..5c6c40f --- /dev/null +++ b/resources/js/Components/Admin/MissingLiveryCard.vue @@ -0,0 +1,57 @@ + + + diff --git a/resources/js/Components/FlightsGoneBy/AirlineAlphabetTable.vue b/resources/js/Components/FlightsGoneBy/AirlineAlphabetTable.vue index 6b6326a..cdc0022 100644 --- a/resources/js/Components/FlightsGoneBy/AirlineAlphabetTable.vue +++ b/resources/js/Components/FlightsGoneBy/AirlineAlphabetTable.vue @@ -4,6 +4,7 @@ import type { CodeType } from '@/Composables/useAlphabetAirlines' import BadgeTable from '@/Components/FlightsGoneBy/GenericBadgeTable.vue' import InlineBadge from '@/Components/FlightsGoneBy/InlineBadge.vue' import AirlineLogo from "@/Components/FlightsGoneBy/AirlineLogo.vue"; +import {computed} from "vue"; const props = defineProps<{ letters: string[] @@ -50,8 +51,8 @@ function isHighlighted({ firstYear }: AirlineEntry): boolean { return props.selectedYear !== null && firstYear === props.selectedYear } -function toBBCode(): string { - return props.letters +const bbCode = computed(() => + props.letters .map(letter => { const entries = airlineEntriesForLetter(letter) if (!entries.length) return letter @@ -65,9 +66,9 @@ function toBBCode(): string { .join(', ') }) .join('\n') -} +) -defineExpose({ toBBCode }) +defineExpose({ bbCode })