Prosp30
Download PDF using Spatie Laravel-PDF on table action
I managed to do it
return response()->streamDownload(function () use ($record) {
echo base64_decode(Pdf::view('pdf.invoice', ['invoice' => $record])
->format('a4')
->footerView('pdf.invoicefooter')
->name('your-invoice.pdf')
->base64());
}, 'test' . '.pdf');
23 replies
Download PDF using Spatie Laravel-PDF on table action
I am trying to do it this way, but no luck. Any ideas?
return response()->streamDownload(function () use ($record) {
Pdf::html('<p>test</p>')
->format('a4')
->name('your-invoice.pdf');
}, 'test' . '.pdf');
23 replies
Very slow app
Also, be careful when using relations... Ie
$this->products and $this->products() are not the same...
One fetches the relation, other one makes an SQL query that fetches ALL the records in that relation, and then uses your where clauses...
10 replies
textInput live error
I did the following
Lets say in db field name is unit_price
I make a hidden field named unit_price. Thats the one that gets updated. Then I use a presentational field named unitPrice, thats the one where user inputs some numbers. Once the user is done, the field gets formatted the way I want it (currency) and before the formatting, I set the numeric value of unit_price.
Also I check in afterStateUpdate on unitPrice if the field is empty, less than 0 etc and set both fields to 0.
Not the greatest solutiom but it works.
For edit page, just use mutateFormBeforeFill and set unitPrice value from unit_price
Also, I use fkoatval on mutateFormDataBeforeSave on unit_price just to be sure its the right type 😁
34 replies
InfoList TextEntry alignEnd() only applies to text but not Label
Try using inlineLabel()
Had the same issue, haven't found a way to get it on the right.
Or try using a PlaceHolder before that one with value of your label, and keep the labels empty
4 replies
Custom text format
Non editable, auto filled. I looked into it, since theres only a set of amount of fields, I just use regex to check if the format is okay and then use string replace on a model function, when the value needs to be calculated and returned to the TextInput field. Works great.
I was kinda hoping something like that exists in Filament, since it keeps blowing me away with how some things are simple ti make 😁
4 replies
Tenancy or alternative?
You could use login listener. Have each new user a certain status. On login, if user has that status, redirect the user to a custom page where there's a form.
Alternatively, you could overwrite register part of the app, and instead of a single form use a form wizard where user needs to input all the details. Then handle the registration and write everything where it needs to go
7 replies
Update pivot table when editing record
I managed to save it and make it editable by using
User CreatePage
protected function handleRecordCreation(array $data): Model
...
$tenant->users()->attach($user->id, ['operator_id' => $data['teamUser_operator_id']]);
EditUser
protected function handleRecordUpdate(Model $record, array $data): Model
{
$record->update($data);
$record->getCurrentTeamUser()->update(['operator_id' => $data['teamUser_operator_id']]);
return $record;
}
Got it to display the data correctly on the table, but still having issues on making it sortable... Any help would be appreciated 🙂
TextColumn::make("teamUser.operator_id")->label('Oznaka operatera')
->getStateUsing(fn ($record) => $record->getUserInTeam()->first()->pivot->operator_id),
3 replies