diff --git a/src/Http/Controllers/Tools/MoonsController.php b/src/Http/Controllers/Tools/MoonsController.php index cd12df462..1fbe05227 100644 --- a/src/Http/Controllers/Tools/MoonsController.php +++ b/src/Http/Controllers/Tools/MoonsController.php @@ -125,6 +125,7 @@ public function store(ProbeReport $request) $universe_moon = UniverseMoonReport::firstOrNew(['moon_id' => $component->moonID]); $universe_moon->user_id = auth()->user()->getAuthIdentifier(); $universe_moon->updated_at = now(); + $universe_moon->notes = $request->notes; $universe_moon->save(); // search for any existing and outdated report regarding current moon @@ -158,4 +159,19 @@ public function destroy(UniverseMoonReport $report) return redirect()->back(); } + + /** + * @param int $moon + * @return \Illuminate\Http\JsonResponse + */ + public function edit(int $moon) + { + $moon = UniverseMoonReport::with('content')->where('moon_id', $moon)->first(); + if($moon == null) return response()->json([], 400); + + return response()->json([ + 'report' => $moon->formatReport(), + 'notes' => $moon->notes, + ]); + } } diff --git a/src/Http/Routes/Tools/Moons.php b/src/Http/Routes/Tools/Moons.php index e49000999..702e7ad58 100644 --- a/src/Http/Routes/Tools/Moons.php +++ b/src/Http/Routes/Tools/Moons.php @@ -34,6 +34,10 @@ ->name('seatcore::tools.moons.show') ->uses('MoonsController@show'); + Route::get('/{id}/edit') + ->name('seatcore::tools.moons.edit') + ->uses('MoonsController@edit'); + Route::post('/') ->name('seatcore::tools.moons.store') ->uses('MoonsController@store') diff --git a/src/Http/Validation/ProbeReport.php b/src/Http/Validation/ProbeReport.php index cf044b6a8..a1355812b 100644 --- a/src/Http/Validation/ProbeReport.php +++ b/src/Http/Validation/ProbeReport.php @@ -46,6 +46,7 @@ public function rules() { return [ 'moon-report' => 'required', + 'notes' => 'present|string', ]; } } diff --git a/src/Models/UniverseMoonReport.php b/src/Models/UniverseMoonReport.php index 5596e31b7..a4a467ef1 100644 --- a/src/Models/UniverseMoonReport.php +++ b/src/Models/UniverseMoonReport.php @@ -147,6 +147,29 @@ public function scopeExceptional($query) }); } + /** + * Converts the moon back into a report string. + * + * @return string + */ + public function formatReport(): string + { + // header + moon name + $report = sprintf("Moon Moon Product\tQuantity\tOre TypeID\tSolarSystemID\tPlanetID\tMoonID\n%s\n", $this->moon->name); + + foreach ($this->content as $content){ + $report .= sprintf("\t%s\t%F\t%d\t%d\t%d\t%d\n", + $content->typeName, + $content->pivot->rate, + $content->typeID, + $this->moon->system_id, + $this->moon->planet_id, + $this->moon_id); + } + + return $report; + } + /** * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ diff --git a/src/database/migrations/2025_07_21_000000_add_moon_report_notes.php b/src/database/migrations/2025_07_21_000000_add_moon_report_notes.php new file mode 100644 index 000000000..8a8192de7 --- /dev/null +++ b/src/database/migrations/2025_07_21_000000_add_moon_report_notes.php @@ -0,0 +1,51 @@ +string('notes')->default(''); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('universe_moon_reports', function (Blueprint $table) { + $table->dropColumn('notes'); + }); + } +}; diff --git a/src/resources/lang/de/moons.php b/src/resources/lang/de/moons.php index 82a181156..6a1a596a0 100644 --- a/src/resources/lang/de/moons.php +++ b/src/resources/lang/de/moons.php @@ -33,4 +33,8 @@ 'uncommon' => 'Ungewöhnlich', 'rare' => 'Selten', 'exceptional' => 'Außergewöhnlich', + + 'notes' => 'Notizen', + 'notes_instruction' => 'Du kannst hier Notizen zu den Mond(en) eingeben. Falls du Daten für mehrere Monde gleichzeitig eingibst, wird die Notiz zu allen neuen Monden hinzugefügt.', + 'notes_placeholder' => 'Gib hier Notizen ein', ]; diff --git a/src/resources/lang/en/moons.php b/src/resources/lang/en/moons.php index bb5f30b54..357eff743 100644 --- a/src/resources/lang/en/moons.php +++ b/src/resources/lang/en/moons.php @@ -55,4 +55,7 @@ 'filter_by_constellation' => 'Filter by constellation', 'filter_by_system' => 'Filter by system', 'import' => 'Import', + 'notes' => 'Notes', + 'notes_instruction' => 'You can enter some notes about the moon(s) here. When adding multiple moons, the note will be added to all of them.', + 'notes_placeholder' => 'Enter your notes here', ]; diff --git a/src/resources/views/tools/moons/buttons/action.blade.php b/src/resources/views/tools/moons/buttons/action.blade.php index 67e1cf245..f80a84ca5 100644 --- a/src/resources/views/tools/moons/buttons/action.blade.php +++ b/src/resources/views/tools/moons/buttons/action.blade.php @@ -1,4 +1,5 @@
{{ trans('web::moons.yield_explanation',['volume'=>number_format(Seat\Eveapi\Models\Industry\CorporationIndustryMiningExtraction::BASE_DRILLING_VOLUME, 2),'yield'=>(setting('reprocessing_yield') ?: 0.80) * 100]) }}
@@ -16,6 +19,11 @@{!! trans('web::moons.probe_report_instruction') !!}
+ {!! trans('web::moons.notes_instruction') !!} +
+