buhbailey
ExportAction getColumns from Service class
I’m having an issue trying to export data using ExportAction from a service class, InvoiceService, that generates columns from various models, plus several calculated columns.
I am using an InvoiceObserver watching for an invoice to get created, at which point, it will generate a pdf, then generate a csv file in a format to be used to upload to various billing systems in what is called a Ledes file. I decided to use the observer with a separate InvoiceService class to separate the concerns.
the InvoiceEvent model (belongsTo and account) contains all of the items included on the invoice (rows of records included on the invoice) and is periodically updated during the month adding time entries, costs, etc.
the invoice model gets created at the end of the month, and captures all of the InvoiceEvent(s) for an account.
the invoice model only contains a date, name, account_id, status, and total columns (with timestamps).
The invoice is created first, then run updates on the InvoiceEvent model to add the invoice_id to the InvoiceEvent model, capturing all unbilled items.
It is at that point that we have all the records from InvoiceEvent(s) to be used for the pdf and ledes functions below.
In addition, a few other properties get filled (like totals, tax, etc), then the pdf is run.
All the data gets filled into the invoice and this method works great.
The problem is with the ExportAction for the Ledes csv file.
In the InvoiceService class, I have the following:
No jobs get generated, no csv file is created. Nothing is written to the laravel.log. I cannot figure out why nothing is happening and been stumped for hours with trial and error and code diving, but this is beyond my expertise at this point.
By way of side notes, the InvoiceService class generates columns not found in the invoice (or InvoiceEvent) model. Do I still need to declare the $model property? I tried to set the $model property to the InvoiceService::class but that did not seem to work either.
The exporter class needs to receive all the data from the InvoiceService and use the array values in the getColumns method of the Exporter, however, it is not working as attempted (by passing an array or the collection object in).
I’m using the built in Exporter available from filament and am on version 3.2.66.
Any help is greatly appreciated.
2 replies
Conditional 3rd Step in Wizard (Button Doesn't Change from Create to Next, or vice versa).
I have a toggle component in step 2, when if toggled on, makes step 3 visible. This works fine using the visible method on step 3 with Get $get('toggle') after toggling it on in Step 2. However, the wizard submit button doesn't change to "Next", but instead remains "Create" in Step 2. If I back out to Step 1 with the toggle on in step 2, then back to step 2, the button does change to "Next" on the 2nd time through leading me to believe it was a reactive issue, however, I cannot figure out how to refresh the steps on the toggle resulting in the button change. Also, unless going back and forth through as described above, I cannot get to the otherwise visible in the header, Step 3. I am trial and error'd out on this. Any hints in the right direction is appreciated!
4 replies
Conditionally Show RelationManager in a View
Is there a way to only show the relation manager tab below on a resource page if a certain property in the model is equal to a value? The getRelations method doesn't seem to accept any arguments. I have quite a few hasMany relationships for my main page/model and would like to eliminate a few of the tabs where they are not applicable.
For example, I have an AccountResource page. The account has 10 hasMany relationships to which I’ve created relationship managers and added them to the getRelations static function. If the account is type “A” for example, only 7 of them are applicable. If the account is type “B” a different set of 8 are applicable.
Can this be done?
3 replies
Save file contents of PDF to database longblob field
I’m trying to save the contents of a PDF file into a longblob field of a mariadb database.
I understand that this should be stored in the filesystem, however, the requirements call for the files to be stored in the database.
Inside my form I have a FileUpload that accepts the pdf file type:
DocumentResource.php
Not sure if the afterStateUpdated is the correct method.
I attempted to open the file for reading, however, it fails to open the stream. The error reads no such file or directory, however, that is where the file appears to be getting saved. I tried passing the TemporaryFileUpload and tried using file_get_contents but couldn't get either to work.
Is this a lifecycle hook issue, or am I off base on how this should work? I am new to Filament. I have accomplished this before (saving contents to db) in several projects many years ago with success using $_FILES in php.
createDocument.php
mutateFormDataBeforeCreate the culprit?
15 replies