Compare commits
3
Commits
45b4b49b83
...
866b45b01d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
866b45b01d | ||
|
|
b3047e9571 | ||
|
|
267fd6fd12 |
@@ -102,6 +102,7 @@ class UserProfileController extends Controller
|
||||
$canView = Gate::allows('viewProfileData', $user);
|
||||
|
||||
$achievements = Achievement::with(['category', 'difficulty'])
|
||||
->orderBy('id', 'asc')
|
||||
->get()
|
||||
->groupBy(fn(Achievement $a) => $a->category->name)
|
||||
->map(fn($group) => $group->sortBy('sort_order')->values());
|
||||
@@ -171,6 +172,11 @@ class UserProfileController extends Controller
|
||||
default => null,
|
||||
};
|
||||
|
||||
$majorAlliances = match($achievement->internal_name){
|
||||
'airlines_alliances.all_major_alliances' => Alliance::MAJOR_ALLIANCES,
|
||||
default => [],
|
||||
};
|
||||
|
||||
$continents = match($achievement->internal_name){
|
||||
'countries_continents.all_continent_pairs_one_way', 'countries_continents.all_continent_pairs_both_ways' => Continent::all()->toArray(),
|
||||
default => [],
|
||||
@@ -207,6 +213,7 @@ class UserProfileController extends Controller
|
||||
'continents' => $continents,
|
||||
'aircraft_families' => $aircraftFamilies,
|
||||
'achievementCount' => $user->unlockedAchievements()->count(),
|
||||
'majorAlliances' => Alliance::whereIn('internal_name', $majorAlliances)->get(),
|
||||
'canView' => $canView,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ class Alliance extends Model
|
||||
'skyteam' => 'airlines_alliances.all_skyteam',
|
||||
];
|
||||
|
||||
const array MAJOR_ALLIANCES = ['skyteam', 'oneworld', 'star_alliance'];
|
||||
|
||||
|
||||
public function airlines(): HasMany
|
||||
{
|
||||
return $this->hasMany(Airline::class);
|
||||
|
||||
@@ -28,6 +28,12 @@ class AirlinesAndAlliancesChecker extends BaseChecker
|
||||
|
||||
$check = fn(string $alliance): int => $flownAllianceAirlines->get($alliance, 0);
|
||||
|
||||
$majorAlliancesFlown = collect(Alliance::MAJOR_ALLIANCES)
|
||||
->filter(fn(string $alliance) => $check($alliance) > 0)
|
||||
->count();
|
||||
|
||||
$this->awardProgress($majorAlliancesFlown, 'airlines_alliances.all_major_alliances');
|
||||
|
||||
$this->awardProgress($check('skyteam'), 'airlines_alliances.all_skyteam');
|
||||
$this->awardProgress($check('oneworld'), 'airlines_alliances.all_oneworld');
|
||||
$this->awardProgress($check('star_alliance'), 'airlines_alliances.all_star_alliance');
|
||||
@@ -40,6 +46,8 @@ class AirlinesAndAlliancesChecker extends BaseChecker
|
||||
|
||||
$checkGroup = fn(array $group): int => $flownAirlines->intersect($group)->count();
|
||||
|
||||
|
||||
|
||||
$this->awardProgress($checkGroup(self::ME_3), 'airlines_alliances.me3');
|
||||
$this->awardProgress($checkGroup(self::US_3), 'airlines_alliances.us3');
|
||||
$this->awardProgress($checkGroup(self::CN_3), 'airlines_alliances.cn3');
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Achievement;
|
||||
use App\Models\AchievementCategory;
|
||||
use App\Models\AchievementDifficulty;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$moderate = AchievementDifficulty::where('internal_name', 'moderate')->first();
|
||||
$airlines_and_alliances = AchievementCategory::where('internal_name', 'airlines_and_alliances')->first();
|
||||
|
||||
Achievement::create([
|
||||
'name' => 'Allied Forces',
|
||||
'internal_name' => 'airlines_alliances.all_major_alliances',
|
||||
'short_description' => 'Fly The 3 Major Airline Alliances (Skyteam, Star Alliance, Oneworld)',
|
||||
'progressive' => true,
|
||||
'difficulty_description' => 'For most people in most parts of the world this is quite achievable',
|
||||
'threshold' => 3,
|
||||
'achievement_category_id' => $airlines_and_alliances->id,
|
||||
'achievement_difficulty_id' => $moderate->id,
|
||||
'has_page' => true,
|
||||
'sort_order' => 1,
|
||||
'icon' => 'standard_achievement.png',
|
||||
'long_description' => '',
|
||||
]);
|
||||
|
||||
Achievement::where('internal_name', 'airlines_alliances.cn3')->update(['sort_order' => 3]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.us3')->update(['sort_order' => 1]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.me3')->update(['sort_order' => 2]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.all_major_alliances')->update(['sort_order' => 4]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.all_skyteam')->update(['sort_order' => 5]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.all_oneworld')->update(['sort_order' => 6]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.all_star_alliance')->update(['sort_order' => 7]);
|
||||
Achievement::where('internal_name', 'airlines_alliances.all_vanilla_alliance')->update(['sort_order' => 8]);
|
||||
|
||||
|
||||
foreach(User::all() as $user){
|
||||
$user->calculateAchievements();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
@@ -1,125 +1,115 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Achievement, Airline, Alliance, Flight, User } from '@/Types/types'
|
||||
import { computed } from 'vue'
|
||||
import { Achievement, Alliance, Flight, User } from '@/Types/types'
|
||||
import Panel from '@/Components/FlightsGoneBy/Panels/Panel.vue'
|
||||
import PanelHeader from '@/Components/FlightsGoneBy/Panels/PanelHeader.vue'
|
||||
import PanelSubHeader from '@/Components/FlightsGoneBy/Panels/PanelSubHeader.vue'
|
||||
import BadgeTable from '@/Components/FlightsGoneBy/GenericBadgeTable.vue'
|
||||
import InlineBadge from '@/Components/FlightsGoneBy/InlineBadge.vue'
|
||||
import AirlineLogo from '@/Components/FlightsGoneBy/AirlineLogo.vue'
|
||||
import AllianceLogo from '@/Components/FlightsGoneBy/AllianceLogo.vue'
|
||||
import FlightBadge from "@/Components/FlightsGoneBy/FlightBadge.vue";
|
||||
import FlightBadge from '@/Components/FlightsGoneBy/FlightBadge.vue'
|
||||
|
||||
|
||||
interface AirlineEntry {
|
||||
airline: Airline
|
||||
flights: Flight[]
|
||||
}
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
const props = defineProps<{
|
||||
achievement: Achievement
|
||||
user: User
|
||||
followStatus: string
|
||||
alliance: Alliance
|
||||
airlines: Airline[]
|
||||
majorAlliances: Alliance[]
|
||||
flights: Flight[]
|
||||
}>()
|
||||
|
||||
const flightsByAirline = computed(() => {
|
||||
const map = new Map<string, AirlineEntry>()
|
||||
const idToKey = new Map<number, string>()
|
||||
interface AllianceEntry {
|
||||
alliance: Alliance
|
||||
flights: Flight[]
|
||||
}
|
||||
|
||||
|
||||
for (const airline of props.airlines) {
|
||||
const key = rowKey(airline)
|
||||
map.set(key, { airline, flights: [] })
|
||||
idToKey.set(airline.id, key)
|
||||
for (const alias of airline.merged_from ?? []) {
|
||||
idToKey.set(alias.id, key)
|
||||
}
|
||||
}
|
||||
const alliances = computed<AllianceEntry[]>(() => {
|
||||
const entries = props.majorAlliances.map(alliance => ({ alliance, flights: [] as Flight[] }))
|
||||
const byName = new Map(entries.map(e => [e.alliance.internal_name, e]))
|
||||
|
||||
for (const flight of props.flights) {
|
||||
const airline = flight.airline
|
||||
if (!airline) continue
|
||||
const key = idToKey.get(airline.id)
|
||||
const key = flight.airline?.alliance?.internal_name
|
||||
if (!key) continue
|
||||
map.get(key)?.flights.push(flight)
|
||||
byName.get(key)?.flights.push(flight)
|
||||
}
|
||||
|
||||
return map
|
||||
return entries
|
||||
})
|
||||
|
||||
function rowKey(airline: Airline): string {
|
||||
return airline.iata_code ?? airline.internal_name
|
||||
const completedCount = computed(
|
||||
() => alliances.value.filter(a => a.flights.length > 0).length
|
||||
)
|
||||
|
||||
function flightTitle(flight: Flight): string {
|
||||
const name = flight.airline?.name ?? 'Unknown airline'
|
||||
return `${name}: ${flight.departure_airport?.iata_code} → ${flight.arrival_airport?.iata_code}`
|
||||
}
|
||||
|
||||
const rows = computed(() => [...flightsByAirline.value.keys()])
|
||||
|
||||
function entryFor(key: string): AirlineEntry {
|
||||
return flightsByAirline.value.get(key)!
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Header -->
|
||||
<Panel>
|
||||
<div class="alliance-header">
|
||||
<AllianceLogo :alliance="alliance" size="56" />
|
||||
<div class="logo-row">
|
||||
<AllianceLogo
|
||||
v-for="entry in alliances"
|
||||
:key="entry.alliance.internal_name"
|
||||
:alliance="entry.alliance"
|
||||
size="56"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<PanelHeader centered>{{ alliance.name }}</PanelHeader>
|
||||
<PanelHeader centered>Major Alliances</PanelHeader>
|
||||
<PanelSubHeader centered>
|
||||
<slot />
|
||||
{{ completedCount }} / {{ alliances.length }} alliances flown
|
||||
</PanelSubHeader>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
|
||||
<!-- Airlines table -->
|
||||
<Panel>
|
||||
<!-- Per-alliance breakdown -->
|
||||
<Panel v-for="entry in alliances" :key="entry.alliance.internal_name">
|
||||
<div class="table-toolbar">
|
||||
<PanelHeader>Airlines</PanelHeader>
|
||||
<PanelHeader>{{ entry.alliance.name }}</PanelHeader>
|
||||
</div>
|
||||
|
||||
<BadgeTable
|
||||
:rows="rows"
|
||||
:rows="[entry.alliance.internal_name]"
|
||||
:rowKey="key => key"
|
||||
:hasItems="key => entryFor(key).flights.length > 0"
|
||||
:hasItems="() => entry.flights.length > 0"
|
||||
labelWidth="14em"
|
||||
>
|
||||
<template #label="{ row: key }">
|
||||
<div class="airline-label" >
|
||||
<AirlineLogo :airline="entryFor(key).airline" size="24" />
|
||||
<span>{{ entryFor(key).airline.name }}</span>
|
||||
<template #label>
|
||||
<div class="airline-label">
|
||||
<AllianceLogo :alliance="entry.alliance" size="24" />
|
||||
<span>{{ entry.alliance.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #items="{ row: key }">
|
||||
<template #items>
|
||||
<FlightBadge
|
||||
v-for="flight in entryFor(key).flights"
|
||||
v-for="flight in entry.flights"
|
||||
:key="flight.id"
|
||||
:title="`${flight.departure_airport?.iata_code} → ${flight.arrival_airport?.iata_code}`"
|
||||
:flight="flight" />
|
||||
:title="flightTitle(flight)"
|
||||
:flight="flight"
|
||||
/>
|
||||
</template>
|
||||
</BadgeTable>
|
||||
</Panel>
|
||||
|
||||
<!-- Slot for alliance-specific panels -->
|
||||
<slot name="extra" />
|
||||
|
||||
<!-- Requirements -->
|
||||
<Panel>
|
||||
<PanelHeader centered>Requirements</PanelHeader>
|
||||
<p>
|
||||
To complete this challenge you must fly with every current member airline of
|
||||
<strong>{{ alliance.name }}</strong>. Alliance membership changes over time, so the
|
||||
required airlines reflect the current roster.
|
||||
To complete this challenge you must fly with at least one member airline from each of
|
||||
the three major alliances. Unlike the individual alliance challenges, you don't need
|
||||
to fly every airline in an alliance — just one flight per alliance is enough.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Codeshare flights do not count, the operating carrier must be a member of {{alliance.name}}.
|
||||
Codeshare flights do not count, the operating carrier must be a member of the
|
||||
alliance.
|
||||
</p>
|
||||
</Panel>
|
||||
</template>
|
||||
@@ -133,6 +123,10 @@ function entryFor(key: string): AirlineEntry {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.logo-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
@@ -142,7 +136,6 @@ function entryFor(key: string): AirlineEntry {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
|
||||
.airline-label {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
@@ -150,5 +143,4 @@ function entryFor(key: string): AirlineEntry {
|
||||
gap: 0.5rem;
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -659,7 +659,7 @@ export default defineComponent({
|
||||
|
||||
const fitBounds = (): void => {
|
||||
if (!props.flights.length) return
|
||||
const padding = props.compact ? 40 : 60
|
||||
const padding = props.compact ? 50 : 60
|
||||
|
||||
const lngs = props.flights.flatMap(f => [f.departure_airport.longitude_deg, f.arrival_airport.longitude_deg])
|
||||
const lats = props.flights.flatMap(f => [f.departure_airport.latitude_deg, f.arrival_airport.latitude_deg])
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { Achievement, Alliance, Flight, User } from '@/Types/types'
|
||||
import Panel from '@/Components/FlightsGoneBy/Panels/Panel.vue'
|
||||
import PanelHeader from '@/Components/FlightsGoneBy/Panels/PanelHeader.vue'
|
||||
import PanelSubHeader from '@/Components/FlightsGoneBy/Panels/PanelSubHeader.vue'
|
||||
import BadgeTable from '@/Components/FlightsGoneBy/GenericBadgeTable.vue'
|
||||
import AllianceLogo from '@/Components/FlightsGoneBy/AllianceLogo.vue'
|
||||
import FlightBadge from '@/Components/FlightsGoneBy/FlightBadge.vue'
|
||||
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
const props = defineProps<{
|
||||
achievement: Achievement
|
||||
user: User
|
||||
followStatus: string
|
||||
majorAlliances: Alliance[]
|
||||
flights: Flight[]
|
||||
}>()
|
||||
|
||||
interface AllianceEntry {
|
||||
alliance: Alliance
|
||||
flights: Flight[]
|
||||
}
|
||||
|
||||
const alliances = computed<AllianceEntry[]>(() => {
|
||||
const entries = props.majorAlliances.map(alliance => ({ alliance, flights: [] as Flight[] }))
|
||||
const byName = new Map(entries.map(e => [e.alliance.internal_name, e]))
|
||||
|
||||
for (const flight of props.flights) {
|
||||
const key = flight.airline?.alliance?.internal_name
|
||||
if (!key) continue
|
||||
byName.get(key)?.flights.push(flight)
|
||||
}
|
||||
|
||||
return entries
|
||||
})
|
||||
|
||||
const rows = computed(() => alliances.value.map(e => e.alliance.internal_name))
|
||||
|
||||
function entryFor(key: string): AllianceEntry {
|
||||
return alliances.value.find(e => e.alliance.internal_name === key)!
|
||||
}
|
||||
|
||||
const completedCount = computed(
|
||||
() => alliances.value.filter(a => a.flights.length > 0).length
|
||||
)
|
||||
|
||||
function flightTitle(flight: Flight): string {
|
||||
const name = flight.airline?.name ?? 'Unknown airline'
|
||||
return `${name}: ${flight.departure_airport?.iata_code} → ${flight.arrival_airport?.iata_code}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Header -->
|
||||
<Panel>
|
||||
<div class="alliance-header">
|
||||
<div class="logo-row">
|
||||
<AllianceLogo
|
||||
v-for="entry in alliances"
|
||||
:key="entry.alliance.internal_name"
|
||||
:alliance="entry.alliance"
|
||||
size="56"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<!-- Alliances table -->
|
||||
<Panel>
|
||||
<div class="table-toolbar">
|
||||
<PanelHeader>Alliances</PanelHeader>
|
||||
</div>
|
||||
|
||||
<BadgeTable
|
||||
:rows="rows"
|
||||
:rowKey="key => key"
|
||||
:hasItems="key => entryFor(key).flights.length > 0"
|
||||
labelWidth="14em"
|
||||
>
|
||||
<template #label="{ row: key }">
|
||||
<div class="airline-label">
|
||||
<AllianceLogo :alliance="entryFor(key).alliance" size="24" />
|
||||
<span>{{ entryFor(key).alliance.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #items="{ row: key }">
|
||||
<FlightBadge
|
||||
v-for="flight in entryFor(key).flights"
|
||||
:key="flight.id"
|
||||
:title="flightTitle(flight)"
|
||||
:flight="flight"
|
||||
/>
|
||||
</template>
|
||||
</BadgeTable>
|
||||
</Panel>
|
||||
|
||||
<!-- Requirements -->
|
||||
<Panel>
|
||||
<PanelHeader centered>Requirements</PanelHeader>
|
||||
<p>
|
||||
To complete this challenge you must fly with at least one member airline from each of
|
||||
the three major alliances. Unlike the individual alliance challenges, you don't need
|
||||
to fly every airline in an alliance — just one flight per alliance is enough.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Codeshare flights do not count, the operating carrier must be a member of the
|
||||
alliance.
|
||||
</p>
|
||||
</Panel>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.alliance-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.logo-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.airline-label {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
</style>
|
||||
@@ -26,6 +26,7 @@ const props = defineProps<{
|
||||
airlines: Airline[]
|
||||
continents: Continent[]
|
||||
aircraft_families: Record<string, string[]>
|
||||
majorAlliances: Alliance[]
|
||||
achievementCount: number
|
||||
canView: boolean
|
||||
}>()
|
||||
@@ -63,7 +64,7 @@ const unlocked = computed(() => {
|
||||
|
||||
<VAlert type="info" v-if="loggedInUser?.id !== user.id && loggedInUser">
|
||||
You are viewing {{user.name}}'s progress in this achievement. If you would like to see your progress, please
|
||||
<Link :href="route('profile.achievement', {user: loggedInUser.name, achievement: achievement.internal_name})"><VBtn variant="flat">click here.</VBtn></Link>
|
||||
<Link :href="route('profile.achievement', {user: loggedInUser.name, achievement: achievement.internal_name})"><u>click here.</u></Link>
|
||||
</VAlert>
|
||||
|
||||
|
||||
@@ -116,6 +117,7 @@ const unlocked = computed(() => {
|
||||
:alliance="alliance"
|
||||
:continents="continents"
|
||||
:families="aircraft_families"
|
||||
:major-alliances="majorAlliances"
|
||||
/>
|
||||
</div>
|
||||
</ProfileLayout>
|
||||
|
||||
Reference in New Issue
Block a user