From 26a4bcd8248cef20325178ea990fe3a14bf4db91 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 27 Jan 2026 15:06:20 +0000 Subject: [PATCH] matchmalking bulk --- .../Actions/DownloadMatchmakingTemplate.php | 143 ++++++++++++++++++ app/Nova/MatchmakingProfile.php | 2 + 2 files changed, 145 insertions(+) create mode 100644 app/Nova/Actions/DownloadMatchmakingTemplate.php diff --git a/app/Nova/Actions/DownloadMatchmakingTemplate.php b/app/Nova/Actions/DownloadMatchmakingTemplate.php new file mode 100644 index 000000000..2a0988b14 --- /dev/null +++ b/app/Nova/Actions/DownloadMatchmakingTemplate.php @@ -0,0 +1,143 @@ + 'text/csv; charset=UTF-8', + 'Content-Disposition' => 'attachment; filename="' . $filename . '"', + 'Pragma' => 'no-cache', + 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', + 'Expires' => '0', + ]; + + $callback = function () use ($csvHeaders, $exampleRow, $validOrgTypes, $validCollaboration, $validFormats) { + $stream = fopen('php://output', 'w'); + + // Add BOM for Excel compatibility + fprintf($stream, chr(0xEF).chr(0xBB).chr(0xBF)); + + // Write headers + fputcsv($stream, $csvHeaders); + + // Write example row + fputcsv($stream, $exampleRow); + + // Write a comment row with valid options + fputcsv($stream, ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['VALID OPTIONS:', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['Organisation type options:', $validOrgTypes, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['Collaboration options:', $validCollaboration, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['Format options:', $validFormats, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['NOTES:', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['- Multiple values should be separated by semicolons (;)', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['- Boolean fields: Yes/No', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['- Dates should be in format: YYYY-MM-DD HH:MM:SS', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + fputcsv($stream, ['- Country should be the full country name (e.g., "Belgium", "United States")', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']); + + fclose($stream); + }; + + return new StreamedResponse($callback, 200, $httpHeaders); + } + + /** + * Get the fields available on the action. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @return array + */ + public function fields(NovaRequest $request): array + { + return []; + } + + /** + * Indicate that this action can be run without any models. + * + * @return bool + */ + public function standalone() + { + return true; + } +} diff --git a/app/Nova/MatchmakingProfile.php b/app/Nova/MatchmakingProfile.php index 24427489d..b1663831f 100644 --- a/app/Nova/MatchmakingProfile.php +++ b/app/Nova/MatchmakingProfile.php @@ -4,6 +4,7 @@ use App\MatchmakingProfile as MatchmakingProfileModel; use App\Nova\Actions\ImportMatchmakingProfiles; +use App\Nova\Actions\DownloadMatchmakingTemplate; use Illuminate\Http\Request; use Laravel\Nova\Fields\ID; use Laravel\Nova\Http\Requests\NovaRequest; @@ -109,6 +110,7 @@ public function fields(Request $request) public function actions(NovaRequest $request): array { return [ + new DownloadMatchmakingTemplate, new ImportMatchmakingProfiles, ]; }