NickNyamu
NickNyamu
FFilament
Created by NickNyamu on 5/15/2024 in #❓┊help
How do you delete a PDF file from storage after the Edit.(only changing the FileUpload)
This worked, thanks! public function updated(LegislationPdf $legislationPdf): void { if ($legislationPdf->isDirty('pdf')) { Storage::disk('public')->delete($legislationPdf->getOriginal('pdf')); } }
7 replies
FFilament
Created by NickNyamu on 5/15/2024 in #❓┊help
How do you delete a PDF file from storage after the Edit.(only changing the FileUpload)
So how do you do that specifically so that when you do an edit, you don't make a deletion and you've altered a different field on the form and saved. ->schema([ Section::make([ Select::make('legislation_id') ->required() ->label('Legislation') ->relationship('legislation', 'title'), Forms\Components\FileUpload::make('pdf') ->required() ->openable() ->downloadable() ->directory('legislation') ->helperText('Upload a PDF file, ensure no two files have similar names to avoid loss of files!') ->preserveFilenames() ->acceptedFileTypes(['application/pdf']) ->label('PDF'), Forms\Components\DatePicker::make('date') ->required(), Select::make('status') ->required() ->options(PdfStatus::class) ]), ]); }
7 replies